-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
std.posix: Added 'error.ProcessNotFound' where necessary #23268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not really clear on the conditions under which we get |
(Let me preface this comment by saying, do whatever Alex says, and feel free to ignore me.) I think this PR correctly maps the errno code on read/write when operating on a Also since POSIX defines From what I can tell (in the Doing this mapping at I think Zig's posix layer can get away with specializing some errno from some syscalls. But I think it'll be hard to do that correctly from syscalls like My suggestion on this PR is that the |
I generally agree with that. As suggested, "process not found" could of course return "file not found." I'm completely unenthusiastic about this and just want to avoid further confusion, because at that point, you're working with "processes" and not with files. Not from a technical point of view (everything is a file), but from a logical point of view. Personally, I'd stick with "process," because when you're working with it, you think of PID as a process and not a file. |
(Again, I'm not a Zig team member, so my opinions may be ignored and I may be off-base.) The problem I'm trying to convince you about is that the Zig's My comments here are all about the pre-existing mappings of (**) The |
I was under the impression that |
Yes, and that hasn't changed. The error message returned by the Linux kernel varies depending on the combination of how a PID is accessed or can no longer be accessed because it no longer exists. We can now catch both possible error types and return them as 'process not found' in Zig, which logically is always the case. Or we can ignore the fact that it's accessing a process and simply write "file not found." I'm still in favor of option 1 and find option 2 clumsy because it's extremely confusing (as Linux often is, unfortunately). We have the option of outputting explanatory error messages, so why not use them? Addendum: The Linux manual pages also say, "The proc filesystem is a pseudo-filesystem...", so I find the error message "procress not found" much more meaningful than "file not found". |
I actually have a question: What a specific situation/example where |
…tencies. After extensive testing, the error messages for processes that are already open but no longer available for reading/writing have been adjusted to 'ProcessNotFound' if the error code ESRCH is thrown by the Linux kernel. Incorrect ENOENT error codes that also returned 'ProcessNotFound' have been removed.
To be honest, I don't remember. I had a test setup consisting of a C program and a Zig program, and I was getting corresponding error codes. Now I tried to recreate it, but to no avail. So I tested everything again from the beginning and only got ESRCH. I've now adjusted this PR accordingly. |
LGTM! |
commit 92d1276 has a typo in its commit message @chrboesch |
Strange, F and P aren't even next to each other on the keyboard... |
@alexrp Is something missing? |
I'm confused. Was ENOENT observed before, or not? Is it now mapped to error.Unexpected after this patch? |
In my first test scenario a few months ago, I was certain that EOENT was occurring. I can't actually reproduce that in the current, somewhat more comprehensive scenario, so it was removed. I've now run several tests in all directions, and all errors that occur are correctly returned. Sorry for confusing, but these tests are unfortunately not automatable. |
If you attempt to
read
(or other operations) from a process previously opened viaopenat
, but it has since terminated, the Linux kernel throws the errorESRCH - No such process
. This is now represented byerror.ProcessNotFound
.fixes #19875