From: Dr. David Alan Gilbert Date: Mon, 18 Aug 2025 22:59:10 +0000 (+0100) Subject: man/man3/posix_spawn.3: EXAMPLES: Validate the number of arguments X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1144819ff0d6dab063627b9f138b5cc4f7098e85;p=thirdparty%2Fman-pages.git man/man3/posix_spawn.3: EXAMPLES: Validate the number of arguments Make the example check for an executable name on the command line rather than segfaulting in the child. Signed-off-by: Dr. David Alan Gilbert Message-ID: <20250818225910.101238-1-dave@treblig.org> Signed-off-by: Alejandro Colomar --- diff --git a/man/man3/posix_spawn.3 b/man/man3/posix_spawn.3 index 3aaf3873e..c4c5b3c96 100644 --- a/man/man3/posix_spawn.3 +++ b/man/man3/posix_spawn.3 @@ -730,6 +730,11 @@ main(int argc, char *argv[]) break; } } +\& + if (argv[optind] == NULL) { + fprintf(stderr, "Usage: %s [\-cs] executable [args]\[rs]n", argv[0]); + exit(EXIT_FAILURE); + } \& /* Spawn the child. The name of the program to execute and the command\-line arguments are taken from the command\-line arguments