Killing jobs?

Alexander Krause alexander.krause at erazor-zone.de
Fri Jun 1 09:25:04 UTC 2007


Hi.

> Have you tried it on a normal system?  I was trying it on debian using
> bash and it doesn't work either.  It works if you use `kill %1` from
> the normal bash shell but it doesn't work the from a script like you
> specified.
Yes, it does.

A test-script:

#!/bin/sh
quit() {
	kill %1
	exit 0
}
fnc1() {
	while true; do
		sleep 1
		echo 'Foreground job running'
	done
}
fnc2() {
	while true; do
		sleep 1
		echo 'Background job running'
	done
}


trap 'quit' 1
trap 'quit' 2
trap 'quit' 3
trap 'quit' 9


fnc2 &
fnc1

----
So, if you use kill -1 or simply Ctr+C both the shell and the subshell is 
killed. If i remove the kill %1, the background job still lives.

Well, now i changed the she-bang to: #!/bin/busybox sh
And after a kill -1 i get:
Foreground job running
Background job running
kill: invalid number '%1'
rzr64 erazor # Background job running
Background job running
Background job running

BTW, is it possible BB does not know about %1 in quit() ? Cos i also tried to 
do something like that:
CPID=$(jobs -p)

That would give me the process-id of that subshell but in $() jobs does not 
return anything.


-- 
Alexander Krause
Amtmann-Kästner-Platz 11
99091 Erfurt

Mail alexander.krause at erazor-zone.de
Tel. +49 (179) 4725826
Fax. +49 (361) 6008915



More information about the busybox mailing list