Simply kill $( jobs -p ) not work in dash.
For example in dash:
$ sleep 999 &
$ kill $(jobs -p)
dash: 2: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]
$
Simply kill $( jobs -p ) not work in dash.
For example in dash:
$ sleep 999 &
$ kill $(jobs -p)
dash: 2: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]
$
Make a bug report to the maintainers of dash.
It seems that dash does return empty output in case that jobs is run in a subshell.
Do you really need to use dash? It is know for not being POSIX compliant for several reasons.
dashas an interactive shell, or did you happen upon this when trying to debug some script? Notice that thatkill $(jobs -p)will not kill all the background jobs, but only the job/program group leaders: even inbash, if you run(sleep 3600; echo DONE) &, and thenkill $(jobs -p), thesleepprocess will not be killed. – Dec 25 '19 at 23:35jobs -p > tmpfile; kill $(cat tmpfile)-- and that's the very best Q you can get while not questioning any of the dubious assumptions ;-) – Dec 25 '19 at 23:44dashas an interactive shell(i.e. both the "interactive" and the "monitor" options are enabled(i.e. on)). – illiterate Dec 26 '19 at 18:22kill $(jobs -p)will not kill all the background processes or jobs. – Dec 26 '19 at 23:31pkill -s0; but if your interractive shell you call that from is not the session leader, that may also kill processes not started from it. – Dec 26 '19 at 23:35jobs -presult?jobs -p > pipe; kill $(cat pipe)just hanging, even I tryjobs -p &I just get empty when read the pipe(cat pipe). – illiterate Dec 27 '19 at 14:38killasynchronously.(kill -TERM $(sed s/^/-/ fifo)&); jobs -p > fifo– Dec 28 '19 at 00:03