diff options
author | Roger A. Faulkner <Roger.Faulkner@Sun.COM> | 2008-09-18 14:55:01 -0700 |
---|---|---|
committer | Roger A. Faulkner <Roger.Faulkner@Sun.COM> | 2008-09-18 14:55:01 -0700 |
commit | f9f6ed06923c6f348695de4d5185b4013adc4b6b (patch) | |
tree | 7eb352258a379ad0290639bfdf3dc7c719334c48 /usr/src/lib/libc/port/stdio/system.c | |
parent | 96b4c1d03653527efc1e65ed6664c671edb89239 (diff) | |
download | illumos-gate-f9f6ed06923c6f348695de4d5185b4013adc4b6b.tar.gz |
6505278 UNIX98/UNIX03: *vsx* system() call to create child, but fail to execute, does not return 127 status
Diffstat (limited to 'usr/src/lib/libc/port/stdio/system.c')
-rw-r--r-- | usr/src/lib/libc/port/stdio/system.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr/src/lib/libc/port/stdio/system.c b/usr/src/lib/libc/port/stdio/system.c index 2837e96353..90dc28e063 100644 --- a/usr/src/lib/libc/port/stdio/system.c +++ b/usr/src/lib/libc/port/stdio/system.c @@ -27,8 +27,6 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "lint.h" #include "mtlib.h" #include <sys/types.h> @@ -154,6 +152,7 @@ system(const char *cmd) /* * Initialize the posix_spawn() attributes structure. + * * The setting of POSIX_SPAWN_WAITPID_NP ensures that no * wait-for-multiple wait() operation will reap our child * and that the child will not be automatically reaped due @@ -161,12 +160,25 @@ system(const char *cmd) * Only a specific wait for the specific pid will be able * to reap the child. Since no other thread knows the pid * of our child, this should be safe enough. + * + * The POSIX_SPAWN_NOEXECERR_NP flag tells posix_spawn() not + * to fail if the shell cannot be executed, but rather cause + * a child to be created that simply performs _exit(127). + * This is in order to satisfy the Posix requirement on system(): + * The system function shall behave as if a child process were + * created using fork(), and the child process invoked the sh + * utility using execl(). If some error prevents the command + * language interpreter from executing after the child process + * is created, the return value from system() shall be as if + * the command language interpreter had terminated using + * exit(127) or _exit(127). */ error = posix_spawnattr_init(&attr); if (error == 0) error = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF | - POSIX_SPAWN_NOSIGCHLD_NP | POSIX_SPAWN_WAITPID_NP); + POSIX_SPAWN_NOSIGCHLD_NP | POSIX_SPAWN_WAITPID_NP | + POSIX_SPAWN_NOEXECERR_NP); /* * The POSIX spec for system() requires us to block SIGCHLD, |