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

Diff of /monit/spawn.c

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

revision 1.26 by hauk, Mon Jul 14 19:55:01 2003 UTC revision 1.27 by martinp, Tue Jul 22 19:51:19 2003 UTC
# Line 118  void  spawn(Service_T S, Command_T C) { Line 118  void  spawn(Service_T S, Command_T C) {
118                
119      } else  {      } else  {
120    
121          int i;
122          int max_descriptors = 1024;
123                
124        /*        /*
125         * Reset all signals, so the child process is         * Reset all signals, so the child process is
# Line 136  void  spawn(Service_T S, Command_T C) { Line 138  void  spawn(Service_T S, Command_T C) {
138         */         */
139        umask(Run.umask);        umask(Run.umask);
140    
       if(! Run.isdaemon) {  
         redirect_stdfd();  
       }  
         
141        if(C->has_gid) {        if(C->has_gid) {
142          if(0 != setgid(C->gid)) {          if(0 != setgid(C->gid)) {
143            log("Failed to change gid to '%d' for '%s'\n",            log("Failed to change gid to '%d' for '%s'\n",
# Line 155  void  spawn(Service_T S, Command_T C) { Line 153  void  spawn(Service_T S, Command_T C) {
153    
154        set_monit_environment(S, C);        set_monit_environment(S, C);
155                
156          log_close();
157    
158          /*
159           * Require that the other file descriptios are closed. Everything
160           * seems to have getdtablesize, so we'll use it here, and back
161           * out to use 1024 if getdtablesize not available.
162           */
163    #ifdef HAVE_UNISTD_H
164          max_descriptors = getdtablesize();
165    #endif
166          for(i = 3; i < max_descriptors; i++)
167            (void) close(i);
168          errno= 0;
169    
170          if(! Run.isdaemon) {
171            redirect_stdfd();
172          }
173          
174        (void) execv(C->arg[0], C->arg);        (void) execv(C->arg[0], C->arg);
175    
176        exec_alert_mail(S, C);        exec_alert_mail(S, C);
177        log("Error: Could not execute %s\n", C->arg[0]);        if(log_init()) {
178            log("Error: Could not execute %s\n", C->arg[0]);
179            log_close();
180          }
181        _exit(1);        _exit(1);
182                
183      }      }

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

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