exec*
calls usually do not return. If they return then only because exec
failed to load the new process image. In that case the error is returned in errno
.
If you are interested in the exit status of your child process then you have to either install a signal handler for SIGCHLD
or wait
for your child in the parent and retrieve the exit status that way.
For your own convenience you may want to consider using system
instead:
int exit_status = system("who | grep user");