Skip to content

Commit 206bd1c

Browse files
authored
Merge pull request #23268 from chrboesch/i19875
std.posix: Added 'error.ProcessNotFound' where necessary
1 parent 667035f commit 206bd1c

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

lib/std/fs.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ pub const SelfExePathError = error{
512512

513513
/// On Windows, `\\server` or `\\server\share` was not found.
514514
NetworkNotFound,
515+
ProcessNotFound,
515516

516517
/// On Windows, antivirus software is enabled by default. It can be
517518
/// disabled, but Windows Update sometimes ignores the user's preference

lib/std/fs/Dir.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ pub const OpenError = error{
784784
DeviceBusy,
785785
/// On Windows, `\\server` or `\\server\share` was not found.
786786
NetworkNotFound,
787+
ProcessNotFound,
787788
} || posix.UnexpectedError;
788789

789790
pub fn close(self: *Dir) void {
@@ -1696,6 +1697,7 @@ pub const DeleteDirError = error{
16961697
BadPathName,
16971698
/// On Windows, `\\server` or `\\server\share` was not found.
16981699
NetworkNotFound,
1700+
ProcessNotFound,
16991701
Unexpected,
17001702
};
17011703

@@ -2005,6 +2007,7 @@ pub const DeleteTreeError = error{
20052007
FileSystem,
20062008
FileBusy,
20072009
DeviceBusy,
2010+
ProcessNotFound,
20082011

20092012
/// One of the path components was not a directory.
20102013
/// 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 {
20792082
error.PermissionDenied,
20802083
error.SymLinkLoop,
20812084
error.ProcessFdQuotaExceeded,
2085+
error.ProcessNotFound,
20822086
error.NameTooLong,
20832087
error.SystemFdQuotaExceeded,
20842088
error.NoDevice,
@@ -2175,6 +2179,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
21752179
error.AccessDenied,
21762180
error.PermissionDenied,
21772181
error.SymLinkLoop,
2182+
error.ProcessNotFound,
21782183
error.ProcessFdQuotaExceeded,
21792184
error.NameTooLong,
21802185
error.SystemFdQuotaExceeded,
@@ -2282,6 +2287,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
22822287
error.AccessDenied,
22832288
error.PermissionDenied,
22842289
error.SymLinkLoop,
2290+
error.ProcessNotFound,
22852291
error.ProcessFdQuotaExceeded,
22862292
error.NameTooLong,
22872293
error.SystemFdQuotaExceeded,
@@ -2383,6 +2389,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
23832389
error.PermissionDenied,
23842390
error.SymLinkLoop,
23852391
error.ProcessFdQuotaExceeded,
2392+
error.ProcessNotFound,
23862393
error.NameTooLong,
23872394
error.SystemFdQuotaExceeded,
23882395
error.NoDevice,

lib/std/fs/File.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub const OpenError = error{
5252
Unexpected,
5353
/// On Windows, `\\server` or `\\server\share` was not found.
5454
NetworkNotFound,
55+
ProcessNotFound,
5556
/// On Windows, antivirus software is enabled by default. It can be
5657
/// disabled, but Windows Update sometimes ignores the user's preference
5758
/// and re-enables it. When enabled, antivirus software on Windows

lib/std/posix.zig

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
869869
.INTR => continue,
870870
.INVAL => unreachable,
871871
.FAULT => unreachable,
872-
.NOENT => return error.ProcessNotFound,
872+
.SRCH => return error.ProcessNotFound,
873873
.AGAIN => return error.WouldBlock,
874874
.CANCELED => return error.Canceled,
875875
.BADF => return error.NotOpenForReading, // Can be a race condition.
@@ -933,7 +933,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize {
933933
.INTR => continue,
934934
.INVAL => unreachable,
935935
.FAULT => unreachable,
936-
.NOENT => return error.ProcessNotFound,
936+
.SRCH => return error.ProcessNotFound,
937937
.AGAIN => return error.WouldBlock,
938938
.BADF => return error.NotOpenForReading, // can be a race condition
939939
.IO => return error.InputOutput,
@@ -1013,7 +1013,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
10131013
.INTR => continue,
10141014
.INVAL => unreachable,
10151015
.FAULT => unreachable,
1016-
.NOENT => return error.ProcessNotFound,
1016+
.SRCH => return error.ProcessNotFound,
10171017
.AGAIN => return error.WouldBlock,
10181018
.BADF => return error.NotOpenForReading, // Can be a race condition.
10191019
.IO => return error.InputOutput,
@@ -1155,7 +1155,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
11551155
.INTR => continue,
11561156
.INVAL => unreachable,
11571157
.FAULT => unreachable,
1158-
.NOENT => return error.ProcessNotFound,
1158+
.SRCH => return error.ProcessNotFound,
11591159
.AGAIN => return error.WouldBlock,
11601160
.BADF => return error.NotOpenForReading, // can be a race condition
11611161
.IO => return error.InputOutput,
@@ -1277,7 +1277,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
12771277
.INTR => continue,
12781278
.INVAL => return error.InvalidArgument,
12791279
.FAULT => unreachable,
1280-
.NOENT => return error.ProcessNotFound,
1280+
.SRCH => return error.ProcessNotFound,
12811281
.AGAIN => return error.WouldBlock,
12821282
.BADF => return error.NotOpenForWriting, // can be a race condition.
12831283
.DESTADDRREQ => unreachable, // `connect` was never called.
@@ -1353,7 +1353,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
13531353
.INTR => continue,
13541354
.INVAL => return error.InvalidArgument,
13551355
.FAULT => unreachable,
1356-
.NOENT => return error.ProcessNotFound,
1356+
.SRCH => return error.ProcessNotFound,
13571357
.AGAIN => return error.WouldBlock,
13581358
.BADF => return error.NotOpenForWriting, // Can be a race condition.
13591359
.DESTADDRREQ => unreachable, // `connect` was never called.
@@ -1443,7 +1443,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
14431443
.INTR => continue,
14441444
.INVAL => return error.InvalidArgument,
14451445
.FAULT => unreachable,
1446-
.NOENT => return error.ProcessNotFound,
1446+
.SRCH => return error.ProcessNotFound,
14471447
.AGAIN => return error.WouldBlock,
14481448
.BADF => return error.NotOpenForWriting, // Can be a race condition.
14491449
.DESTADDRREQ => unreachable, // `connect` was never called.
@@ -1528,7 +1528,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
15281528
.INTR => continue,
15291529
.INVAL => return error.InvalidArgument,
15301530
.FAULT => unreachable,
1531-
.NOENT => return error.ProcessNotFound,
1531+
.SRCH => return error.ProcessNotFound,
15321532
.AGAIN => return error.WouldBlock,
15331533
.BADF => return error.NotOpenForWriting, // Can be a race condition.
15341534
.DESTADDRREQ => unreachable, // `connect` was never called.
@@ -1607,6 +1607,9 @@ pub const OpenError = error{
16071607
/// On Windows, `\\server` or `\\server\share` was not found.
16081608
NetworkNotFound,
16091609

1610+
/// This error occurs in Linux if the process to be open was not found.
1611+
ProcessNotFound,
1612+
16101613
/// One of these three things:
16111614
/// * pathname refers to an executable image which is currently being
16121615
/// 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 {
16661669
.NFILE => return error.SystemFdQuotaExceeded,
16671670
.NODEV => return error.NoDevice,
16681671
.NOENT => return error.FileNotFound,
1672+
.SRCH => return error.ProcessNotFound,
16691673
.NOMEM => return error.SystemResources,
16701674
.NOSPC => return error.NoSpaceLeft,
16711675
.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
18371841
.NFILE => return error.SystemFdQuotaExceeded,
18381842
.NODEV => return error.NoDevice,
18391843
.NOENT => return error.FileNotFound,
1844+
.SRCH => return error.ProcessNotFound,
18401845
.NOMEM => return error.SystemResources,
18411846
.NOSPC => return error.NoSpaceLeft,
18421847
.NOTDIR => return error.NotDir,
@@ -5483,6 +5488,7 @@ pub const RealPathError = error{
54835488
FileSystem,
54845489
BadPathName,
54855490
DeviceBusy,
5491+
ProcessNotFound,
54865492

54875493
SharingViolation,
54885494
PipeBusy,

lib/std/zig/system.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
843843
error.NoDevice,
844844
=> return error.GLibCNotFound,
845845

846+
error.ProcessNotFound,
846847
error.ProcessFdQuotaExceeded,
847848
error.SystemFdQuotaExceeded,
848849
error.SystemResources,
@@ -886,6 +887,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion {
886887

887888
error.FileTooBig => return error.Unexpected,
888889

890+
error.ProcessNotFound,
889891
error.ProcessFdQuotaExceeded,
890892
error.SystemFdQuotaExceeded,
891893
error.SystemResources,

0 commit comments

Comments
 (0)