diff options
Diffstat (limited to 'man3/posix_spawn.3')
-rw-r--r-- | man3/posix_spawn.3 | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/man3/posix_spawn.3 b/man3/posix_spawn.3 index 6dbad2ea0..32fa8b373 100644 --- a/man3/posix_spawn.3 +++ b/man3/posix_spawn.3 @@ -8,7 +8,7 @@ .\" POSIX 1003.1-2004 documentation .\" (http://www.opengroup.org/onlinepubs/009695399) .\" -.TH posix_spawn 3 2023-02-05 "Linux man-pages 6.03" +.TH posix_spawn 3 2023-05-03 "Linux man-pages 6.05.01" .SH NAME posix_spawn, posix_spawnp \- spawn a process .SH LIBRARY @@ -508,14 +508,11 @@ In addition, these functions fail if: .TP .B ENOSYS Function not supported on this system. -.SH VERSIONS -The -.BR posix_spawn () -and -.BR posix_spawnp () -functions are available since glibc 2.2. .SH STANDARDS -POSIX.1-2001, POSIX.1-2008. +POSIX.1-2008. +.SH HISTORY +glibc 2.2. +POSIX.1-2001. .\" FIXME . This piece belongs in spawnattr_setflags(3) .\" The .\" .B POSIX_SPAWN_USEVFORK @@ -638,7 +635,7 @@ can't be blocked). $ \fB./a.out \-s sleep 60 &\fP [1] 7637 $ PID of child: 7638 - +.PP $ \fBkill 7638\fP $ \fBkill \-KILL 7638\fP $ Child status: killed by signal 9 @@ -669,16 +666,16 @@ Child status: exited, status=127 #include <string.h> #include <unistd.h> #include <wait.h> - +\& #define errExit(msg) do { perror(msg); \e exit(EXIT_FAILURE); } while (0) - +\& #define errExitEN(en, msg) \e do { errno = en; perror(msg); \e exit(EXIT_FAILURE); } while (0) - +\& char **environ; - +\& int main(int argc, char *argv[]) { @@ -689,87 +686,87 @@ main(int argc, char *argv[]) posix_spawnattr_t *attrp; posix_spawn_file_actions_t file_actions; posix_spawn_file_actions_t *file_actionsp; - +\& /* Parse command\-line options, which can be used to specify an attributes object and file actions object for the child. */ - +\& attrp = NULL; file_actionsp = NULL; - +\& while ((opt = getopt(argc, argv, "sc")) != \-1) { switch (opt) { case \[aq]c\[aq]: /* \-c: close standard output in child */ - +\& /* Create a file actions object and add a "close" action to it. */ - +\& s = posix_spawn_file_actions_init(&file_actions); if (s != 0) errExitEN(s, "posix_spawn_file_actions_init"); - +\& s = posix_spawn_file_actions_addclose(&file_actions, STDOUT_FILENO); if (s != 0) errExitEN(s, "posix_spawn_file_actions_addclose"); - +\& file_actionsp = &file_actions; break; - +\& case \[aq]s\[aq]: /* \-s: block all signals in child */ - +\& /* Create an attributes object and add a "set signal mask" action to it. */ - +\& s = posix_spawnattr_init(&attr); if (s != 0) errExitEN(s, "posix_spawnattr_init"); s = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK); if (s != 0) errExitEN(s, "posix_spawnattr_setflags"); - +\& sigfillset(&mask); s = posix_spawnattr_setsigmask(&attr, &mask); if (s != 0) errExitEN(s, "posix_spawnattr_setsigmask"); - +\& attrp = &attr; break; } } - +\& /* Spawn the child. The name of the program to execute and the command\-line arguments are taken from the command\-line arguments of this program. The environment of the program execed in the child is made the same as the parent\[aq]s environment. */ - +\& s = posix_spawnp(&child_pid, argv[optind], file_actionsp, attrp, &argv[optind], environ); if (s != 0) errExitEN(s, "posix_spawn"); - +\& /* Destroy any objects that we created earlier. */ - +\& if (attrp != NULL) { s = posix_spawnattr_destroy(attrp); if (s != 0) errExitEN(s, "posix_spawnattr_destroy"); } - +\& if (file_actionsp != NULL) { s = posix_spawn_file_actions_destroy(file_actionsp); if (s != 0) errExitEN(s, "posix_spawn_file_actions_destroy"); } - +\& printf("PID of child: %jd\en", (intmax_t) child_pid); - +\& /* Monitor status of the child until it terminates. */ - +\& do { s = waitpid(child_pid, &status, WUNTRACED | WCONTINUED); if (s == \-1) errExit("waitpid"); - +\& printf("Child status: "); if (WIFEXITED(status)) { printf("exited, status=%d\en", WEXITSTATUS(status)); @@ -781,7 +778,7 @@ main(int argc, char *argv[]) printf("continued\en"); } } while (!WIFEXITED(status) && !WIFSIGNALED(status)); - +\& exit(EXIT_SUCCESS); } .EE |