/[monit]/monit/spawn.c
ViewVC logotype

Diff of /monit/spawn.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by hauk, Tue Nov 5 12:24:35 2002 UTC revision 1.16 by hauk, Sat Dec 21 13:56:04 2002 UTC
# Line 86  void  spawn(Process_T P, Command_T C) { Line 86  void  spawn(Process_T P, Command_T C) {
86    pid_t pid;    pid_t pid;
87    sigset_t mask, save;    sigset_t mask, save;
88    
89      ASSERT(P);
90      ASSERT(C);
91      
92    /*    /*
93     * Block SIGCHLD     * Block SIGCHLD
94     */     */
# Line 93  void  spawn(Process_T P, Command_T C) { Line 96  void  spawn(Process_T P, Command_T C) {
96    sigaddset(&mask, SIGCHLD);    sigaddset(&mask, SIGCHLD);
97    pthread_sigmask(SIG_BLOCK, &mask, &save);    pthread_sigmask(SIG_BLOCK, &mask, &save);
98        
99    if ((pid= fork ()) < 0) {    if((pid= fork()) < 0) {
100            
101      log("Cannot fork of a new process\n");        log("Cannot fork of a new process\n");  
102      exit (1);      exit(1);
103            
104    }  else if ( pid == 0 ) {    }  else if(pid == 0) {
105            
106      if ( (pid= fork()) < 0 ) {      if((pid= fork()) < 0) {
107                
108        log("Cannot fork of a new process\n");          log("Cannot fork of a new process\n");  
109        exit (1);        exit(1);
110                
111      }      }
112            
113      else if ( pid > 0 ) {      else if(pid > 0) {
114                
115        _exit(0);        _exit(0);
116                
# Line 149  void  spawn(Process_T P, Command_T C) { Line 152  void  spawn(Process_T P, Command_T C) {
152        sendmail(alert_list);        sendmail(alert_list);
153        log("Could not execute %s\n", c->arg[0]);        log("Could not execute %s\n", c->arg[0]);
154        gc_mail_list(&alert_list);        gc_mail_list(&alert_list);
155        _exit (1);        _exit(1);
156                
157      }      }
158    }    }
159    
160    /* Wait for first child - aka second parent, to exit */    /* Wait for first child - aka second parent, to exit */
161    if ( waitpid(pid, NULL, 0) != pid ) {    if(waitpid(pid, NULL, 0) != pid) {
162            
163        log("Waitpid error\n");        log("Waitpid error\n");
164    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26