Re: POSIX.1 and SIGCHLD

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

 



On Sunday 18 June 2006 09:51, Dinesh Ahuja wrote:
> As per older handling of SIGCHLD, if we set the
> disposition of SIGHCHLD to be caught, the kernel
> immediately checks if there are aby child processes
> ready to be waited for and , if so, calls SIGCHLD
> behavior.
>
> Following code snipped should give out of stack space
> and should terminate.
> // Signal Handler for SIGCHLD
> static void sig_chld()
> {
>     int status;
>     pid_t pid;
>     signal(SIGCHLD,sig_chld);
>
>     pid = wait(&status);
>     return;
> }
>
> I fully agree that POSIX signals are reliable and
> hence we need not set signal handler again in signal
> handler. But what should happen if I do it explicitly?

What happens to the registered handler is system dependent.
Use sigaction() for more explicit and portable behavior.

> I was expecting to have a recursive call to signal
> handler and hence out of stack should have occured.

I wouldn't expect that.

> But the aboVe code works fine on Linux Kernel 2.4.20.
> How does POSIX handles if we establish a signal
> handler and there exists a terminated child which
> needs to be waited for.

I believe the signal handler needs to be registered before the
child dies or it won't be called.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux