Re: set -m under setsid doesn't create pgrp's

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

 



On Tue, Feb 15, 2011 at 10:45:58AM +0000, Dan Muresan wrote:
> dash (0.5.5.1-3ubuntu2) doesn't seem put jobs in their own pgrp when
> setsid'ed, as required by the "set -o monitor" (set -m) option:
> 
> 
> $ cat >test.sh <<EOF
> #!/bin/sh
> set -m
> sh -c 'while :; do sleep 3; done' &
> set +m
> echo "Waiting for $!"; wait; echo Done
> EOF
> 
> $ setsid test.sh
> Waiting for 25828
> $ kill -- -25828
> kill: (-25828) - No such process
> $ ps -Leo pid,ppid,pgrp,cmd  # pgrp of job is pid of test.sh
> 
> This does not happen with bash, or if running the script directly
> without setsid.

This is not a bug.  setsid causes the shell to run with no
controlling terminal, which makes proper job control impossible.

Other shells simply ignore the error while continuing to provide
limited job control.

So if you want job control with setsid, you must ensure that
a controlling tty is attached afterwards.

Cheers,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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