Re: Possible bug in wait4(), 2.1.126-129 ?

Robert Thoerncrantz (rtz@pirx.df.lth.se)
Tue, 24 Nov 1998 00:26:51 +0100


On Mon, Nov 23, 1998 at 05:38:49AM -0500, Ion Badulescu wrote:
> Can *anybody* reproduce this behavior? I refuse to believe I'm the only
> one who sees it, I can reproduce it locally on 30+ boxes and two different
> architectures (intel and ultrasparc)! It's simple: compile the attached C
> program, run it on a rh51 box from cron, as any user, and it should send
> you a mail with the message:
>
> wait4: No child processes
>
> Thanks,
> Ion

My guess would be that it probably depends on how cron has
been compiled to set the signal handlers for your cron jobs.

Try running this program from cron. If you get the "SIGCHLD is
ignored..." message, you will never get any zombies to wait for,
unless you change the signal handlers yourself in your job.

/robert

-----------------------------------------------------------------
#include <stdio.h>
#include <signal.h>

int main(void)
{
struct sigaction new,old;

/* We are only interested in the old sigaction struct,
but we have to set the new to something, make it empty
and generic. */

new.sa_handler=SIG_DFL;
sigemptyset(&new.sa_mask);
new.sa_flags=SA_RESTART;

if(sigaction(SIGCHLD,&new,&old)==-1) {
/* Eeep! */
perror("sigaction");
exit(1);
}
if(old.sa_handler==SIG_IGN) {
printf("SIGCHLD is ignored, child processes are reaped\n"
"automatically, wait4() will complain.\n");
} else if (old.sa_handler==SIG_DFL) {
printf("Default action, child processes have "
"to be waited for.\n");
} else {
printf("Strange, this should probably not have happened.\n");
}

return 0;
}

-- 
Robert Thörncrantz                                 rtz@pirx.df.lth.se
Mundus Vult Decipi                              dat95rth@ludat.lth.se
Pgp Key: 0xB30D8661;                5B4617EACD4C0AF1 EF8E3D3FF91523B2

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/