busybox init and rcS
Rob Landley
rob at landley.net
Mon Jan 9 16:44:36 UTC 2006
On Monday 09 January 2006 07:39, hinko.kocevar at cetrtapot.si wrote:
> Rob Landley wrote:
> > Well, first off, could you try a current snapshot so we know we're
> > working with fresh up-to-the-minute bugs? (We're a couple days away from
> > a new release.)
> >
> > Rob
>
> I've did a bit of debugging and found out following. If I modify the
> function waitfor() in init.c like this (see waitpid line and the one
> following it) rcS is started and returns, also shell prompt is shown.
> Without WNOHANG flag for waitpid() and additional message to print on
> CONSOLE it does not work.
Uh-huh. Telling waitpid() to return immediately and _spinning_ on it is a
workaround for something broken, not a fix.
> static int waitfor(const struct init_action *a)
> {
> int pid;
> int status, wpid;
>
> pid = run(a);
> while (1) {
> wpid = waitpid(pid,&status,WNOHANG);
> message(CONSOLE, "po waitpid wpid = %d", wpid);
>
> if (wpid == pid) {
> break;
> }
> if (wpid == -1 && errno == ECHILD) {
> /* we missed its termination */
> break;
> }
> /* FIXME other errors should maybe trigger an error, but allow
> * the program to continue */
> }
> return wpid;
> }
>
> In console I get this output (enabled bit of debugging here):
> ....
> command='/etc/init.d/rcS' action='1' terminal='/dev/ttyS0'
> command='-/bin/sh' action='4' terminal='/dev/ttyS0'
> command='/sbin/init' action='128' terminal='/dev/ttyS0'
> command='/sbin/reboot' action='32' terminal='/dev/ttyS0'
> command='/bin/umount -a -r' action='64' terminal='/dev/ttyS0'
> command='/sbin/swapoff -a' action='64' terminal='/dev/ttyS0'
>
> Starting pid 654, console /dev/ttyS0: '/etc/init.d/rcS'
> po waitpid wpid = 0
> po waitpid wpid = 0
> po waitpid wpid = 0
> po waitpid wpid = 0
>
> ... A LOT OF LINES ...
Well you're spinning instead of waiting.
> po waitpid wpid = 0
> po waitpid wpid = 0
> po waitpid wpid = 0
> po waitpid wpid = 0
> po waitpid wpid = 653
If that's really making a difference, something is wrong with either your
kernel or your C library. It sounds like sigchld is never being delivered.
(You're waiting on a specific pid, so I think it's actually polling that
process's state and will happily do the zombie cleanup even if it ever
actually received a signal.)
How much of a workout have you given the kernel you're running on the axis
etrax? Do you know if signal delivery on the sucker actually works?
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