-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
std.posix: Added error message 'ProcessNotFound' for reading and writing in a Linux process #21430
Conversation
I can't complete this PR due to the complexity of the dependencies. Since I can't test on MacOS or Windows and the error message only says "test-fmt transitive error", I don't know how to fix this. |
It means you have code formatting violations; run |
lib/std/posix.zig
Outdated
@@ -798,6 +798,10 @@ pub const ReadError = error{ | |||
/// In WASI, this error occurs when the file descriptor does | |||
/// not hold the required rights to read from it. | |||
AccessDenied, | |||
|
|||
// This error occurs in Linux if the process to be read from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be doc comments (///
instead of //
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handles ENOENT
aka errno 2 aka error.FileNotFound
, the linked issue is about ESRCH
(errno 3).
Because Linux returns the ENOENT error for a process (aka file) that no longer exists when trying to read or write to it. |
Then it would be good to note that in the original issue so the author knows they're mistaken or can clarify the situation in which |
Actually, I'm not so confident in this change on second thought, given this: giampaolo/psutil@22651a6#diff-d969f5377d3dc82ba7501f4c9f6d6510e1240df2debdca7c726a9ff37fde7af7R1340-R1349 I think this behavior needs to be verified manually. |
What do you mean exactly? |
As in, write a test program that does:
|
I did this manually on two different Linux systems (Arch, Gentoo) to check which error I get. A test program is difficult because the PIDs change every time and in principle two programs have to start, which tell each other the PID they currently have. Would be feasible. Only why? I think the result will be the same as with my tests. And if that changes in Linux (in a future kernel), we have to make adjustments anyway. |
The commit I linked above claims that the returned error for |
I also assumed that an ESRCH error would occur, but I received ENOENT. I then analyzed the kernel source code in 'fs/proc/fd.c', and in the function 'proc_readfd_common', only ENOENT is used. No idea what the Python folks are doing, but ESRCH is definitely not returned on an x64 system. static int proc_readfd_common(struct file *file, struct dir_context *ctx,
instantiate_t instantiate)
{
struct task_struct *p = get_proc_task(file_inode(file));
unsigned int fd;
if (!p)
return -ENOENT;
... |
Please don't post LLM-generated content on the issue tracker. A glorified text prediction engine does not provide any useful perspective or information. |
No prob, I deleted it. |
process. This error occurs if the process to be read from or written to no longer exists. Fixes ziglang#19875
…ing in a Linux process (ziglang#21430) * Added error message 'ProcessNotFound' for reading and writing in a Linux process. This error occurs if the process to be read from or written to no longer exists. Fixes ziglang#19875 * Added error message "ProcessNotFound" for error forwarding. * Add error messgae for forwarding. * Added message for forwarding. * Error set completed. * Fixed format error. * Changed comments to doc comments.
This error occurs if the process to be read from or written to no longer exists.
Fixes #19875