![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can a child process return a specific value to a parent process ? | Ametis1970 | High Level Programming | 8 | 04-09-2008 08:22 PM |
| about child process | compbug | UNIX for Dummies Questions & Answers | 12 | 03-22-2006 03:55 PM |
| Catching signal and piping | joseph_ng | High Level Programming | 7 | 11-14-2005 07:04 AM |
| KDM child process | larryase | UNIX for Dummies Questions & Answers | 6 | 01-24-2005 01:41 PM |
| Child Process PID | skannan | High Level Programming | 2 | 06-10-2002 04:54 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
catching a signal from child process
i am creating children processes using fork system call
every child i create goes to sleep for random time. when child stops running how can i catch his signal and turminate the child |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
void childexit(int signal_num) {
int retval, nval;
char buf[256];
bzero(buf,256);
nval = waitpid(0,&retval,WNOHANG);
sprintf(buf,"Waited on child %d which exited with code = %d\n",nval,retval);
write(STDOUT_FILENO,buf,256);
}
int main(void) {
signal(SIGCHLD,childexit);
/*rest of code*/
}
|
| Thread Tools | |
| Display Modes | |
|
|