ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.98k stars 2.48k forks source link

`ESRCH` is not handled by file io operations #19875

Open breavyn opened 4 months ago

breavyn commented 4 months ago

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

Reading or writing files under /proc/<pid>/ on linux can result in an ESRCH error if the related process has terminated.

Functions read, pread, readv, etc. and their write counterparts, seek, and possibly others, return error.Unexpected in this case.

Expected Behavior

Functions should return error.ProcessNotFound on ESRCH.

chrboesch commented 1 week ago

Reading or writing files under /proc// on linux can result in an ESRCH error if the related process has terminated.

Linux returns the ENOENT error for a process (aka file) that no longer exists when trying to read or write to it. So I added 'ProcessNotFound' on this.

Functions should return error.ProcessNotFound on ESRCH.

This error occurs when you try to kill a process or process group that no longer exists.