Allows dropping a local variable if the explicit PID is not needed
and it makes it clearer what happens.
Also, one should always strive for consistency for cases like these.
Quoting POSIX[0]:
"Care should be taken, also, to call _exit() rather than exit() if exec cannot be used, since
exit() flushes and closes standard I/O channels, thereby damaging the parent process' standard
I/O data structures. (Even with fork(), it is wrong to call exit(), since buffered data would
then be flushed twice.)"
[0]: http://pubs.opengroup.org/onlinepubs/009695399/functions/vfork.html
I just ran a simple one-liner[1] to find the average filepath
length on my system (absolute paths) and that came up with a value
~90 characters. Assume this is out by a factor of two, we still
have potentially 5000 more arguments that we can put into the buffer.
Surely one might run xargs(1) on something that is not a filename.
We just choose to accomodate the common use-case as much as possible.
[1] find / 2>/dev/null | awk '{print length($0)}' \
| awk '{a+=$1}END{print "average filepath length: ",a/NR}'
We cannot rely on ungetc() pushing back more than 1 character
reliably on all systems, so just note if we have leftover input and
process it in the next run.
We still have a few error codes to do, namely when the process
is killed or stopped by a signal or when one or more invocations
of the command returned a nonzero exit status.