msh and cntrl-C on a background process

Rob Landley rob at landley.net
Tue Jan 24 20:55:14 UTC 2006


On Tuesday 24 January 2006 12:13, Robin Getz wrote:
> term (even in the process is run in the background with "&"). To reproduce:
>  > ping 127.0.0.1 &   [ starting ping in background ]
>  > ping 127.0.0.1
>
> CTRL-C
>
> On Desktop bash, and busybox ash &lash - this stops the foreground ping,
> and the one in the background keeps going.
>
> In busybox msh and sash, background processes has the same PGID as TTY and
> will be interrupted by "ctrl-c" since the kernel sends the signal to every
> process with the same parent group IP number.
>
> Is this the expected implementation of "&" in msh and sash?

Nope, that's a bug.

> bash, ash, or lash assign a new group id to a background process. Most
> implemented in this way:
> setpgid(child->pid, newjob->progs[0].pid);

So lash is doing it right?

> Which sets the new background process's pgid identical to its pid, which
> make the process leader of a new process group, and will not be kill by
> ctrl-c.

I hate to say this, but if you could open a bug report in bugs.busybox.net 
(with the above reproduction sequence) so this doesn't get lost in the noise, 
I'd appreciate it.  (Yeah, I hate the bug generator but this is _exactly_ the 
sort of thing it's for.  Real problem, I'm unlikely to have spare brain cells 
to fix it today, and other people could conceivably beat me to it if it's 
recorded somewhere.)

> Since you can't see the pgid with busybox ps, you can check it by looking
> at /proc/pid/status. For example, the /proc/43/stat (43 is the pid of the
> background ping) is:
> 43 (ping) S 23 23 23

I need up upgrade busybox ps too, don't I?

> It is OK to say that this is an application issue - if make an application
> (like boa) which wants to run in the background, it should deamonize itself
> properly by changing the pgid, but this is not how other "full featured"
> shells work.

No, it's a bug in msh.  If you spin off a background process with & it should 
not get ctrl-c.  Easiest thing to do is probably copying the lash code, but I 
also need to figure out how to do a regression testcase for this, and 
probably explain the issue in busybox.net/programming.html (once I'm sure I 
understand the details myself)...

> Thanks in advance.
> -Robin

Thanks for a good bug report.

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list