When is SIGCHLD is raised.


 
Thread Tools Search this Thread
Top Forums Programming When is SIGCHLD is raised.
# 1  
Old 10-20-2005
When is SIGCHLD is raised.

Hi,
I have 2 processes X and Y. Y is exec() from X. In Y i have an exit handler, which is called when i return from main. With in exit handler i delete and object which in turn calls the destructor of the object, which terminates all the threads of Y.

I believe that SIGCHLD is raised by Y as soon as it returns from main().
Or is it done else where.

Sumanth
# 2  
Old 10-20-2005
C programs start with special start-up code that invokes main(). You come back to this stub when you return from main. The stub then invokes exit(). Within exit(), any atexit() routines get invoked. After all of that the system call _exit() is called. The process will never return from this system call...no more user code will run. _exit() will close any open files.

There is a lot of stuff left to be done to shut down the process and different os's do it in different order. One of the things is to send SIGCHLD to the parent. When the parent gets the SIGCHLD signal, the kernel may still be working to finish the _exit() call. If process accounting or C2 security auditing is active this may involve writing records to disk files. But the process is being killed as fast as the kernel can manage it.

One thing though.... System V had a SIGCLD while BSD had a SIGCHLD and they worked differently. Posix boldly decided that the spelling should be SIGCHLD but did not specify which behavior to use. So the parent may be able to set a flag called SA_NOCLDWAIT which will inhibit SIGCHLD from being set at all.
# 3  
Old 10-21-2005
MySQL

OH!! My state is Smilie
Lot of stuff on SIGCHLD, Thanks for the response.
# 4  
Old 10-21-2005
Quote:
Originally Posted by Perderabo
If process accounting or C2 security auditing is active this may involve writing records to disk files.
when _exit system call is triggered none of the atexit used as a exit handler would be invoked and there would not be any flush from std/IO buffer to the kernel buffers as mentioned only file descriptors (if at all open would be closed). It is _exit call which take the status directly to the kernel unlike exit

Writing records to disk files did u mean it from user program's perspective or i misunderstood?

Please explain.
# 5  
Old 10-21-2005
Read again what I posted. I'm not gonna type it again.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using SIGCHLD

I'm testing out how to use SIGCHLD and I had a question about intercepting the signal and executing an action in the signal handler. signal(SIGCHLD,countdown); What I'm trying to achieve is be able to printf(Hello) every second that child is set to sleep. I'm setting sleep = 3; so... (1 Reply)
Discussion started by: l flipboi l
1 Replies

2. Programming

SIGCHLD interrupts its own handler

Hi. I have a program whose job it is to manage 15 child processes. Sometimes these children die (sometimes deliberately other times with a SEGV). This causes a SIGCHLD to be sent to my program which uses waitpid() in the signal handler to gather information and, in most cases, restart the child.... (3 Replies)
Discussion started by: jrichemont
3 Replies

3. Shell Programming and Scripting

Populating array raised an error

Hi, The following test case populate an array named: array3. Since array1 and array2 are equal in length and values array3 will remain empty. #!/usr/bin/ksh test() { set -A array1 "A" set -A array2 "A" NUM_1=`echo ${#array1}` print "num elenemt in NUM_1 is ${NUM_1}" i=1 for ELE2 in... (1 Reply)
Discussion started by: yoavbe
1 Replies

4. Programming

SIGCHLD trace problem

Hello, I'd like to know whether it is possible to let the parent know who kills its child process. The case is likely as below: if there are four processes, we call them A, B, C and D. B is the child of A, and can be killed by both C and D. if B is killed, then A will receive SIGCHLD from B.... (7 Replies)
Discussion started by: aaronwong
7 Replies

5. UNIX for Dummies Questions & Answers

Who sent the process SIGCHLD ?

I want to know whicj process send the signal SIGCHLD to the parent's child. Thank you in advance, (1 Reply)
Discussion started by: Puntino
1 Replies

6. Shell Programming and Scripting

automatically answer a question raised by a command

i have installed vmware on a text base linux node now i have to vmware-configure.pl to do the initial configuration now 1st step it askes for agreeing for a " License Agreement" for that i have to say "q" and "yes" to Accept it i want to run a script with does these 3 steps... (6 Replies)
Discussion started by: pbsrinivas
6 Replies

7. UNIX for Dummies Questions & Answers

About SIGCHLD

When the SIGCHLD is sent? SIGCHLD is sent either a child exits spontaneously (e.g. exit(0)) or it is killed ? thank you in advance (3 Replies)
Discussion started by: Puntino
3 Replies

8. Programming

signal handler for SIGCHLD

Hi, I have an c++ application which uses the function fork and execvp(). The parent does not wait until the child ends. The parents just creates children and let them do their stuff. You can see the parent program as a batch-manager. I have added a SIGCHLD handler to the program: void... (3 Replies)
Discussion started by: jens
3 Replies

9. Programming

Need help with SIGCHLD

Hello everybody, this is my first post on this forum. I have a program that has a child process that sleeps for 5 second and exit. I'm suppose to modify this program so that when the child exits, the parent reports the exit status of the child, so I also have to deal with SIGINT and SIGQUIT. Can... (1 Reply)
Discussion started by: Unlimited Sky
1 Replies
Login or Register to Ask a Question