job control (Re: dash race)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, then.

What script tries to do?

> <================================
> #!/bin/dash
> trap "echo TRAP" USR1
> stub() {
> 	echo ">>> STUB $1" >&2
> 	sleep $1
> 	echo "<<< STUB $1" >&2
> 	kill -USR1 $$
> }
> stub 3 &
> stub 2 &
> until { echo "###"; wait; } do
> 	echo "*** $?"
> done
> ================================>

`dash` is forking; inside functions in "background" $$ is parent's pid:

olecom@flower:/tmp$ /bin/dash -s << '#'
stub(){ exec 2>&1
        echo "STUB $$"
        sleep $1
}
stub 1 & echo $! ; stub 2 & echo $!
exit
#

STUB 15418
15419
STUB 15418
15421
olecom@flower:/tmp$


which is kind of strage. Messing with functions especially in background
isn't a good idea. I wonder what is semantics of functions WRT traps,
forks, signals, etc..


olecom@flower:/tmp$ /bin/dash -c 'fu(){ fu; }; fu'
Segmentation fault
olecom@flower:/tmp$ /bin/bash -c 'fu(){ fu; }; fu'
^C
olecom@flower:/tmp$

Also, `ps` && `kill` is better implementation of job control. dash's
interactivity isn't a good one, so what reason is behind shell's job
control after all?
____
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux