Skip to content

Commit 22e1e23

Browse files
authored
fork() and system(): Change errno value from EAGAIN to ENOSYS (#14173)
This is more correct. Trying again will not help. Fixes: #14124
1 parent 13d6d6c commit 22e1e23

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,4 @@ a license to everyone to use it as detailed in LICENSE.)
565565
* Érico Porto <[email protected]>
566566
* Albert Vaca Cintora <[email protected]>
567567
* Zhi An Ng <[email protected]> (copyright owned by Google, Inc.)
568+
* Ian Jackson <[email protected]>

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ See docs/process.md for more on how version tagging works.
2424
static string data in your program. This has long been part of the native
2525
ELF linker and should not be observable in well-behaved programs. This
2626
behavior can be disabled by passing `-Wl,-O0`.
27+
- The functions `fork`, `vfork`, `posix_spawn` and `system` now fail with
28+
the errno value `ENOSYS` (52) rather than `EAGAIN` (6). This is more
29+
correct, since they will never work and attempting to retry won't help.
2730

2831
2.0.20: 05/04/2021
2932
------------------

src/library.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ LibraryManager.library = {
171171
// pid_t fork(void);
172172
// http://pubs.opengroup.org/onlinepubs/000095399/functions/fork.html
173173
// We don't support multiple processes.
174-
setErrNo({{{ cDefine('EAGAIN') }}});
174+
setErrNo({{{ cDefine('ENOSYS') }}});
175175
return -1;
176176
},
177177
vfork: 'fork',
@@ -411,7 +411,7 @@ LibraryManager.library = {
411411
// http://pubs.opengroup.org/onlinepubs/000095399/functions/system.html
412412
// Can't call external programs.
413413
if (!command) return 0; // no shell available
414-
setErrNo({{{ cDefine('EAGAIN') }}});
414+
setErrNo({{{ cDefine('ENOSYS') }}});
415415
return -1;
416416
},
417417

tests/core/test_support_errno.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
rtn : -1
2-
errno : 6
3-
strerror: Resource temporarily unavailable
2+
errno : 52
3+
strerror: Function not implemented

tests/system.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ int main(void) {
2525
#else
2626
assert(system(NULL) == 0);
2727
assert(system("") == -1);
28-
assert(errno == EAGAIN);
28+
assert(errno == ENOSYS);
2929
assert(system("true") == -1);
30-
assert(errno == EAGAIN);
30+
assert(errno == ENOSYS);
3131
#ifdef REPORT_RESULT
3232
REPORT_RESULT(0);
3333
#endif

tests/unistd/misc.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ lchown(good): 0, errno: 0
2525
lchown(bad): -1, errno: 44
2626
fchown(good): 0, errno: 0
2727
fchown(bad): -1, errno: 8
28-
fork: -1, errno: 6
29-
vfork: -1, errno: 6
28+
fork: -1, errno: 52
29+
vfork: -1, errno: 52
3030
crypt: ba4TuD1iozTxw, errno: 0
3131
encrypt, errno: 0
3232
getgid: 0, errno: 0

0 commit comments

Comments
 (0)