Merge pull request #23268 from chrboesch/i19875

std.posix: Added 'error.ProcessNotFound' where necessary
This commit is contained in:
Chris Boesch 2025-04-14 22:20:44 +02:00 committed by GitHub
parent 667035fc78
commit 206bd1ced8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 8 deletions

View file

@ -512,6 +512,7 @@ pub const SelfExePathError = error{
/// On Windows, `\\server` or `\\server\share` was not found. /// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound, NetworkNotFound,
ProcessNotFound,
/// On Windows, antivirus software is enabled by default. It can be /// On Windows, antivirus software is enabled by default. It can be
/// disabled, but Windows Update sometimes ignores the user's preference /// disabled, but Windows Update sometimes ignores the user's preference

View file

@ -784,6 +784,7 @@ pub const OpenError = error{
DeviceBusy, DeviceBusy,
/// On Windows, `\\server` or `\\server\share` was not found. /// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound, NetworkNotFound,
ProcessNotFound,
} || posix.UnexpectedError; } || posix.UnexpectedError;
pub fn close(self: *Dir) void { pub fn close(self: *Dir) void {
@ -1696,6 +1697,7 @@ pub const DeleteDirError = error{
BadPathName, BadPathName,
/// On Windows, `\\server` or `\\server\share` was not found. /// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound, NetworkNotFound,
ProcessNotFound,
Unexpected, Unexpected,
}; };
@ -2005,6 +2007,7 @@ pub const DeleteTreeError = error{
FileSystem, FileSystem,
FileBusy, FileBusy,
DeviceBusy, DeviceBusy,
ProcessNotFound,
/// One of the path components was not a directory. /// One of the path components was not a directory.
/// This error is unreachable if `sub_path` does not contain a path separator. /// This error is unreachable if `sub_path` does not contain a path separator.
@ -2079,6 +2082,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
error.PermissionDenied, error.PermissionDenied,
error.SymLinkLoop, error.SymLinkLoop,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.ProcessNotFound,
error.NameTooLong, error.NameTooLong,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
error.NoDevice, error.NoDevice,
@ -2175,6 +2179,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
error.AccessDenied, error.AccessDenied,
error.PermissionDenied, error.PermissionDenied,
error.SymLinkLoop, error.SymLinkLoop,
error.ProcessNotFound,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.NameTooLong, error.NameTooLong,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
@ -2282,6 +2287,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
error.AccessDenied, error.AccessDenied,
error.PermissionDenied, error.PermissionDenied,
error.SymLinkLoop, error.SymLinkLoop,
error.ProcessNotFound,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.NameTooLong, error.NameTooLong,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
@ -2383,6 +2389,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
error.PermissionDenied, error.PermissionDenied,
error.SymLinkLoop, error.SymLinkLoop,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.ProcessNotFound,
error.NameTooLong, error.NameTooLong,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
error.NoDevice, error.NoDevice,

View file

@ -52,6 +52,7 @@ pub const OpenError = error{
Unexpected, Unexpected,
/// On Windows, `\\server` or `\\server\share` was not found. /// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound, NetworkNotFound,
ProcessNotFound,
/// On Windows, antivirus software is enabled by default. It can be /// On Windows, antivirus software is enabled by default. It can be
/// disabled, but Windows Update sometimes ignores the user's preference /// disabled, but Windows Update sometimes ignores the user's preference
/// and re-enables it. When enabled, antivirus software on Windows /// and re-enables it. When enabled, antivirus software on Windows

View file

@ -869,7 +869,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
.INTR => continue, .INTR => continue,
.INVAL => unreachable, .INVAL => unreachable,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.CANCELED => return error.Canceled, .CANCELED => return error.Canceled,
.BADF => return error.NotOpenForReading, // Can be a race condition. .BADF => return error.NotOpenForReading, // Can be a race condition.
@ -933,7 +933,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize {
.INTR => continue, .INTR => continue,
.INVAL => unreachable, .INVAL => unreachable,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForReading, // can be a race condition .BADF => return error.NotOpenForReading, // can be a race condition
.IO => return error.InputOutput, .IO => return error.InputOutput,
@ -1013,7 +1013,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
.INTR => continue, .INTR => continue,
.INVAL => unreachable, .INVAL => unreachable,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForReading, // Can be a race condition. .BADF => return error.NotOpenForReading, // Can be a race condition.
.IO => return error.InputOutput, .IO => return error.InputOutput,
@ -1155,7 +1155,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
.INTR => continue, .INTR => continue,
.INVAL => unreachable, .INVAL => unreachable,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForReading, // can be a race condition .BADF => return error.NotOpenForReading, // can be a race condition
.IO => return error.InputOutput, .IO => return error.InputOutput,
@ -1277,7 +1277,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
.INTR => continue, .INTR => continue,
.INVAL => return error.InvalidArgument, .INVAL => return error.InvalidArgument,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForWriting, // can be a race condition. .BADF => return error.NotOpenForWriting, // can be a race condition.
.DESTADDRREQ => unreachable, // `connect` was never called. .DESTADDRREQ => unreachable, // `connect` was never called.
@ -1353,7 +1353,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
.INTR => continue, .INTR => continue,
.INVAL => return error.InvalidArgument, .INVAL => return error.InvalidArgument,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForWriting, // Can be a race condition. .BADF => return error.NotOpenForWriting, // Can be a race condition.
.DESTADDRREQ => unreachable, // `connect` was never called. .DESTADDRREQ => unreachable, // `connect` was never called.
@ -1443,7 +1443,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
.INTR => continue, .INTR => continue,
.INVAL => return error.InvalidArgument, .INVAL => return error.InvalidArgument,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForWriting, // Can be a race condition. .BADF => return error.NotOpenForWriting, // Can be a race condition.
.DESTADDRREQ => unreachable, // `connect` was never called. .DESTADDRREQ => unreachable, // `connect` was never called.
@ -1528,7 +1528,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
.INTR => continue, .INTR => continue,
.INVAL => return error.InvalidArgument, .INVAL => return error.InvalidArgument,
.FAULT => unreachable, .FAULT => unreachable,
.NOENT => return error.ProcessNotFound, .SRCH => return error.ProcessNotFound,
.AGAIN => return error.WouldBlock, .AGAIN => return error.WouldBlock,
.BADF => return error.NotOpenForWriting, // Can be a race condition. .BADF => return error.NotOpenForWriting, // Can be a race condition.
.DESTADDRREQ => unreachable, // `connect` was never called. .DESTADDRREQ => unreachable, // `connect` was never called.
@ -1607,6 +1607,9 @@ pub const OpenError = error{
/// On Windows, `\\server` or `\\server\share` was not found. /// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound, NetworkNotFound,
/// This error occurs in Linux if the process to be open was not found.
ProcessNotFound,
/// One of these three things: /// One of these three things:
/// * pathname refers to an executable image which is currently being /// * pathname refers to an executable image which is currently being
/// executed and write access was requested. /// executed and write access was requested.
@ -1666,6 +1669,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: O, perm: mode_t) OpenError!fd_t {
.NFILE => return error.SystemFdQuotaExceeded, .NFILE => return error.SystemFdQuotaExceeded,
.NODEV => return error.NoDevice, .NODEV => return error.NoDevice,
.NOENT => return error.FileNotFound, .NOENT => return error.FileNotFound,
.SRCH => return error.ProcessNotFound,
.NOMEM => return error.SystemResources, .NOMEM => return error.SystemResources,
.NOSPC => return error.NoSpaceLeft, .NOSPC => return error.NoSpaceLeft,
.NOTDIR => return error.NotDir, .NOTDIR => return error.NotDir,
@ -1837,6 +1841,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: O, mode: mode_t) O
.NFILE => return error.SystemFdQuotaExceeded, .NFILE => return error.SystemFdQuotaExceeded,
.NODEV => return error.NoDevice, .NODEV => return error.NoDevice,
.NOENT => return error.FileNotFound, .NOENT => return error.FileNotFound,
.SRCH => return error.ProcessNotFound,
.NOMEM => return error.SystemResources, .NOMEM => return error.SystemResources,
.NOSPC => return error.NoSpaceLeft, .NOSPC => return error.NoSpaceLeft,
.NOTDIR => return error.NotDir, .NOTDIR => return error.NotDir,
@ -5483,6 +5488,7 @@ pub const RealPathError = error{
FileSystem, FileSystem,
BadPathName, BadPathName,
DeviceBusy, DeviceBusy,
ProcessNotFound,
SharingViolation, SharingViolation,
PipeBusy, PipeBusy,

View file

@ -843,6 +843,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
error.NoDevice, error.NoDevice,
=> return error.GLibCNotFound, => return error.GLibCNotFound,
error.ProcessNotFound,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
error.SystemResources, error.SystemResources,
@ -886,6 +887,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
error.FileTooBig => return error.Unexpected, error.FileTooBig => return error.Unexpected,
error.ProcessNotFound,
error.ProcessFdQuotaExceeded, error.ProcessFdQuotaExceeded,
error.SystemFdQuotaExceeded, error.SystemFdQuotaExceeded,
error.SystemResources, error.SystemResources,