> Remember, POSIX requires kill(1) to be a shell builtin, because it
> must support job syntax ("kill %1", for example), which cannot be
> done with normal POSIX child process semantics.
>
> In that case, one can make the builtin kill a wrapper, that parses the
> command line, and if it see %1 it replaces it with the process job pid
> and passes that to the real kill, or the builtin kill if no system
> kill utiltiy exists.
Write your own shell function that does just that. You can
use 'jobs -p' to find the process number. Something like
this untested snippet (making it robust to arbitrary input
and arbitrary number of arguments is left an exercise to
the reader):
kill()
{
arglist=
for arg in "$*" ; do
case $arg in
%*) arglist="$arglist `jobs -p $arg`" ;;
*) arglist="$arglist $arg" ;;
esac
done
test -x /bin/kill && /bin/kill $arglist || builtin kill $arglist
}
>
> Just cause POSIX says something, doesn't mean that it is right.
True. But in this case, it doesn't make it wrong, either. Another
argument for making kill a builtin is if you hit your ulimit on max
processes, builtin kill will work, but trying an external kill will fail.
--
Eric Blake
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils