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 |
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", |
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 |
} |
} |