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 <dave@treblig.org>
Message-ID: <
20250818225910.101238-1-dave@treblig.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
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