* Question about job control in non-interactive shells
@ 2012-01-09 16:17 Michael Welsh Duggan
2012-01-09 16:37 ` Jonathan Nieder
0 siblings, 1 reply; 4+ messages in thread
From: Michael Welsh Duggan @ 2012-01-09 16:17 UTC (permalink / raw)
To: dash
I am trying to determine why:
dash -c "sleep 5 & kill %1"
results in:
dash: 1: kill: No such process
whereas from an interactive dash
sleep 5 & kill %1
seems to do exactly what it should. Any hints?
--
Michael Welsh Duggan
(mwd@cert.org)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about job control in non-interactive shells
2012-01-09 16:17 Question about job control in non-interactive shells Michael Welsh Duggan
@ 2012-01-09 16:37 ` Jonathan Nieder
2012-01-13 15:49 ` Jilles Tjoelker
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2012-01-09 16:37 UTC (permalink / raw)
To: Michael Welsh Duggan; +Cc: dash
Hi Michael,
Michael Welsh Duggan wrote:
> I am trying to determine why:
>
> dash -c "sleep 5 & kill %1"
>
> results in:
>
> dash: 1: kill: No such process
You are probably looking for the -m option.
Thanks for writing, and hope that helps,
Jonathan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about job control in non-interactive shells
2012-01-09 16:37 ` Jonathan Nieder
@ 2012-01-13 15:49 ` Jilles Tjoelker
2012-01-15 3:53 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Jilles Tjoelker @ 2012-01-13 15:49 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Michael Welsh Duggan, dash
On Mon, Jan 09, 2012 at 10:37:45AM -0600, Jonathan Nieder wrote:
> Michael Welsh Duggan wrote:
> > I am trying to determine why:
> > dash -c "sleep 5 & kill %1"
> > results in:
> > dash: 1: kill: No such process
> You are probably looking for the -m option.
The cause is that the -m option ("job control") enables running commands
in separate process groups, and dash follows literally what POSIX says
about kill %job: a background process group should be signaled; however,
there is no background process group. Some shells signal one or more
processes they know are part of the job in this case, but dash calls
kill() on a process group that is guaranteed not to exist.
--
Jilles Tjoelker
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about job control in non-interactive shells
2012-01-13 15:49 ` Jilles Tjoelker
@ 2012-01-15 3:53 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2012-01-15 3:53 UTC (permalink / raw)
To: Jilles Tjoelker; +Cc: jrnieder, mwd, dash
Jilles Tjoelker <jilles@stack.nl> wrote:
> On Mon, Jan 09, 2012 at 10:37:45AM -0600, Jonathan Nieder wrote:
>> Michael Welsh Duggan wrote:
>> > I am trying to determine why:
>
>> > dash -c "sleep 5 & kill %1"
>
>> > results in:
>
>> > dash: 1: kill: No such process
>
>> You are probably looking for the -m option.
>
> The cause is that the -m option ("job control") enables running commands
> in separate process groups, and dash follows literally what POSIX says
> about kill %job: a background process group should be signaled; however,
> there is no background process group. Some shells signal one or more
> processes they know are part of the job in this case, but dash calls
> kill() on a process group that is guaranteed not to exist.
Right. And you don't even need %1:
dash -c "sleep 5 & kill $!"
works just fine.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-15 3:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 16:17 Question about job control in non-interactive shells Michael Welsh Duggan
2012-01-09 16:37 ` Jonathan Nieder
2012-01-13 15:49 ` Jilles Tjoelker
2012-01-15 3:53 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.