]>
Commit | Line | Data |
---|---|---|
7fafc032 | 1 | /* |
53921bfa | 2 | * udevd.c - hotplug event serializer |
7fafc032 | 3 | * |
7fafc032 | 4 | * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org> |
2f6cbd19 | 5 | * Copyright (C) 2004 Chris Friesen <chris_friesen@sympatico.ca> |
7fafc032 KS |
6 | * |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation version 2 of the License. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License along | |
18 | * with this program; if not, write to the Free Software Foundation, Inc., | |
19 | * 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | * | |
21 | */ | |
22 | ||
a695feae | 23 | #include <stddef.h> |
90c210eb | 24 | #include <sys/wait.h> |
7fafc032 KS |
25 | #include <signal.h> |
26 | #include <unistd.h> | |
27 | #include <errno.h> | |
28 | #include <stdio.h> | |
29 | #include <stdlib.h> | |
30 | #include <string.h> | |
e5a2989e | 31 | #include <sys/time.h> |
53921bfa KS |
32 | #include <sys/types.h> |
33 | #include <sys/socket.h> | |
34 | #include <sys/un.h> | |
f27125f9 | 35 | #include <fcntl.h> |
e5a2989e | 36 | #include "klibc_fixups.h" |
e5a2989e | 37 | #include <sys/sysinfo.h> |
7fafc032 | 38 | |
a695feae | 39 | #include "list.h" |
7fafc032 | 40 | #include "udev.h" |
c81b35c0 | 41 | #include "udev_lib.h" |
35b7d88c | 42 | #include "udev_version.h" |
7fafc032 KS |
43 | #include "udevd.h" |
44 | #include "logging.h" | |
45 | ||
f27125f9 | 46 | static int pipefds[2]; |
3169e8d1 | 47 | static long expected_seqnum = 0; |
2f6cbd19 | 48 | volatile static int children_waiting; |
f27125f9 | 49 | volatile static int run_msg_q; |
50 | volatile static int sig_flag; | |
51 | static int run_exec_q; | |
7fafc032 | 52 | |
4a539daf KS |
53 | static LIST_HEAD(msg_list); |
54 | static LIST_HEAD(exec_list); | |
55 | static LIST_HEAD(running_list); | |
7fafc032 | 56 | |
2f6cbd19 KS |
57 | static void exec_queue_manager(void); |
58 | static void msg_queue_manager(void); | |
f27125f9 | 59 | static void user_sighandler(void); |
60 | static void reap_kids(void); | |
7d855c31 | 61 | char *udev_bin; |
7fafc032 | 62 | |
d026a35d | 63 | #ifdef LOG |
d00bd172 | 64 | unsigned char logname[LOGNAME_SIZE]; |
d026a35d | 65 | void log_message (int level, const char *format, ...) |
51a8bb2f | 66 | { |
d026a35d GKH |
67 | va_list args; |
68 | ||
69 | va_start(args, format); | |
70 | vsyslog(level, format, args); | |
71 | va_end(args); | |
51a8bb2f | 72 | } |
d026a35d | 73 | #endif |
51a8bb2f | 74 | |
b6bf0b12 KS |
75 | #define msg_dump(msg) \ |
76 | dbg("msg_dump: sequence %d, '%s', '%s', '%s'", \ | |
77 | msg->seqnum, msg->action, msg->devpath, msg->subsystem); | |
78 | ||
53921bfa | 79 | static void msg_dump_queue(void) |
7fafc032 | 80 | { |
f27125f9 | 81 | #ifdef DEBUG |
53921bfa | 82 | struct hotplug_msg *msg; |
7fafc032 | 83 | |
53921bfa | 84 | list_for_each_entry(msg, &msg_list, list) |
3169e8d1 | 85 | dbg("sequence %li in queue", msg->seqnum); |
f27125f9 | 86 | #endif |
35b7d88c KS |
87 | } |
88 | ||
53921bfa | 89 | static struct hotplug_msg *msg_create(void) |
35b7d88c | 90 | { |
53921bfa | 91 | struct hotplug_msg *new_msg; |
35b7d88c | 92 | |
53921bfa | 93 | new_msg = malloc(sizeof(struct hotplug_msg)); |
2f6cbd19 | 94 | if (new_msg == NULL) |
53921bfa | 95 | dbg("error malloc"); |
53921bfa | 96 | return new_msg; |
35b7d88c KS |
97 | } |
98 | ||
2f6cbd19 | 99 | static void run_queue_delete(struct hotplug_msg *msg) |
8e2229c4 | 100 | { |
2f6cbd19 KS |
101 | list_del(&msg->list); |
102 | free(msg); | |
8e2229c4 KS |
103 | } |
104 | ||
53921bfa KS |
105 | /* orders the message in the queue by sequence number */ |
106 | static void msg_queue_insert(struct hotplug_msg *msg) | |
35b7d88c | 107 | { |
53921bfa | 108 | struct hotplug_msg *loop_msg; |
e5a2989e | 109 | struct sysinfo info; |
35b7d88c | 110 | |
f27125f9 | 111 | /* sort message by sequence number into list. events |
112 | * will tend to come in order, so scan the list backwards | |
113 | */ | |
114 | list_for_each_entry_reverse(loop_msg, &msg_list, list) | |
115 | if (loop_msg->seqnum < msg->seqnum) | |
53921bfa | 116 | break; |
35b7d88c | 117 | |
53921bfa | 118 | /* store timestamp of queuing */ |
e5a2989e KS |
119 | sysinfo(&info); |
120 | msg->queue_time = info.uptime; | |
121 | ||
122 | list_add(&msg->list, &loop_msg->list); | |
3169e8d1 | 123 | dbg("queued message seq %li", msg->seqnum); |
35b7d88c | 124 | |
2f6cbd19 | 125 | /* run msg queue manager */ |
f27125f9 | 126 | run_msg_q = 1; |
7fafc032 | 127 | |
53921bfa | 128 | return ; |
7fafc032 KS |
129 | } |
130 | ||
53921bfa | 131 | /* forks event and removes event from run queue when finished */ |
2f6cbd19 | 132 | static void udev_run(struct hotplug_msg *msg) |
7fafc032 | 133 | { |
90c210eb | 134 | pid_t pid; |
e964c2c0 KS |
135 | char action[ACTION_SIZE]; |
136 | char devpath[DEVPATH_SIZE]; | |
3169e8d1 KS |
137 | char seqnum[SEQNUM_SIZE]; |
138 | char *env[] = { action, devpath, seqnum, NULL }; | |
f8911dbb | 139 | |
9b28a52a KS |
140 | strcpy(action, "ACTION="); |
141 | strfieldcat(action, msg->action); | |
142 | strcpy(devpath, "DEVPATH="); | |
143 | strfieldcat(devpath, msg->devpath); | |
3169e8d1 KS |
144 | strcpy(seqnum, "SEQNUM="); |
145 | strlongcat(seqnum, msg->seqnum); | |
90c210eb KS |
146 | |
147 | pid = fork(); | |
148 | switch (pid) { | |
149 | case 0: | |
33db4b8d | 150 | /* child */ |
7d855c31 | 151 | execle(udev_bin, "udev", msg->subsystem, NULL, env); |
33db4b8d KS |
152 | dbg("exec of child failed"); |
153 | exit(1); | |
90c210eb KS |
154 | break; |
155 | case -1: | |
33db4b8d | 156 | dbg("fork of child failed"); |
2f6cbd19 | 157 | run_queue_delete(msg); |
f27125f9 | 158 | /* note: we never managed to run, so we had no impact on |
159 | * running_with_devpath(), so don't bother setting run_exec_q | |
160 | */ | |
2f6cbd19 | 161 | break; |
90c210eb | 162 | default: |
2f6cbd19 | 163 | /* get SIGCHLD in main loop */ |
3169e8d1 | 164 | dbg("==> exec seq %li [%d] working at '%s'", msg->seqnum, pid, msg->devpath); |
2f6cbd19 | 165 | msg->pid = pid; |
90c210eb | 166 | } |
7fafc032 KS |
167 | } |
168 | ||
53921bfa KS |
169 | /* returns already running task with devpath */ |
170 | static struct hotplug_msg *running_with_devpath(struct hotplug_msg *msg) | |
7fafc032 | 171 | { |
53921bfa | 172 | struct hotplug_msg *loop_msg; |
2f6cbd19 | 173 | list_for_each_entry(loop_msg, &running_list, list) |
53921bfa KS |
174 | if (strncmp(loop_msg->devpath, msg->devpath, sizeof(loop_msg->devpath)) == 0) |
175 | return loop_msg; | |
176 | return NULL; | |
7fafc032 KS |
177 | } |
178 | ||
2f6cbd19 KS |
179 | /* exec queue management routine executes the events and delays events for the same devpath */ |
180 | static void exec_queue_manager() | |
7fafc032 | 181 | { |
53921bfa KS |
182 | struct hotplug_msg *loop_msg; |
183 | struct hotplug_msg *tmp_msg; | |
a695feae | 184 | struct hotplug_msg *msg; |
53921bfa | 185 | |
2f6cbd19 KS |
186 | list_for_each_entry_safe(loop_msg, tmp_msg, &exec_list, list) { |
187 | msg = running_with_devpath(loop_msg); | |
188 | if (!msg) { | |
189 | /* move event to run list */ | |
190 | list_move_tail(&loop_msg->list, &running_list); | |
191 | udev_run(loop_msg); | |
3169e8d1 | 192 | dbg("moved seq %li to running list", loop_msg->seqnum); |
2f6cbd19 | 193 | } else { |
3169e8d1 | 194 | dbg("delay seq %li, cause seq %li already working on '%s'", |
2f6cbd19 | 195 | loop_msg->seqnum, msg->seqnum, msg->devpath); |
53921bfa | 196 | } |
53921bfa KS |
197 | } |
198 | } | |
199 | ||
2f6cbd19 | 200 | static void msg_move_exec(struct hotplug_msg *msg) |
86590cd5 | 201 | { |
2f6cbd19 | 202 | list_move_tail(&msg->list, &exec_list); |
f27125f9 | 203 | run_exec_q = 1; |
2f6cbd19 | 204 | expected_seqnum = msg->seqnum+1; |
3169e8d1 | 205 | dbg("moved seq %li to exec, next expected is %li", |
2f6cbd19 | 206 | msg->seqnum, expected_seqnum); |
86590cd5 KS |
207 | } |
208 | ||
2f6cbd19 KS |
209 | /* msg queue management routine handles the timeouts and dispatches the events */ |
210 | static void msg_queue_manager() | |
53921bfa KS |
211 | { |
212 | struct hotplug_msg *loop_msg; | |
a695feae | 213 | struct hotplug_msg *tmp_msg; |
e5a2989e KS |
214 | struct sysinfo info; |
215 | long msg_age = 0; | |
a695feae | 216 | |
3169e8d1 | 217 | dbg("msg queue manager, next expected is %li", expected_seqnum); |
a695feae | 218 | recheck: |
2f6cbd19 KS |
219 | list_for_each_entry_safe(loop_msg, tmp_msg, &msg_list, list) { |
220 | /* move event with expected sequence to the exec list */ | |
221 | if (loop_msg->seqnum == expected_seqnum) { | |
222 | msg_move_exec(loop_msg); | |
223 | continue; | |
a695feae | 224 | } |
35b7d88c | 225 | |
2f6cbd19 | 226 | /* move event with expired timeout to the exec list */ |
e5a2989e KS |
227 | sysinfo(&info); |
228 | msg_age = info.uptime - loop_msg->queue_time; | |
3169e8d1 | 229 | dbg("seq %li is %li seconds old", loop_msg->seqnum, msg_age); |
2f6cbd19 KS |
230 | if (msg_age > EVENT_TIMEOUT_SEC-1) { |
231 | msg_move_exec(loop_msg); | |
232 | goto recheck; | |
53921bfa | 233 | } else { |
2f6cbd19 | 234 | break; |
53921bfa | 235 | } |
2f6cbd19 KS |
236 | } |
237 | ||
238 | msg_dump_queue(); | |
239 | ||
e5a2989e | 240 | /* set timeout for remaining queued events */ |
2f6cbd19 | 241 | if (list_empty(&msg_list) == 0) { |
2f6cbd19 | 242 | struct itimerval itv = {{0, 0}, {EVENT_TIMEOUT_SEC - msg_age, 0}}; |
e5a2989e | 243 | dbg("next event expires in %li seconds", EVENT_TIMEOUT_SEC - msg_age); |
2f6cbd19 | 244 | setitimer(ITIMER_REAL, &itv, 0); |
7fafc032 | 245 | } |
7fafc032 KS |
246 | } |
247 | ||
2f6cbd19 KS |
248 | /* receive the msg, do some basic sanity checks, and queue it */ |
249 | static void handle_msg(int sock) | |
7fafc032 | 250 | { |
53921bfa KS |
251 | struct hotplug_msg *msg; |
252 | int retval; | |
0028653c KS |
253 | struct msghdr smsg; |
254 | struct cmsghdr *cmsg; | |
255 | struct iovec iov; | |
256 | struct ucred *cred; | |
257 | char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; | |
a695feae | 258 | |
53921bfa KS |
259 | msg = msg_create(); |
260 | if (msg == NULL) { | |
261 | dbg("unable to store message"); | |
2f6cbd19 | 262 | return; |
7fafc032 | 263 | } |
7fafc032 | 264 | |
0028653c KS |
265 | iov.iov_base = msg; |
266 | iov.iov_len = sizeof(struct hotplug_msg); | |
267 | ||
268 | memset(&smsg, 0x00, sizeof(struct msghdr)); | |
269 | smsg.msg_iov = &iov; | |
270 | smsg.msg_iovlen = 1; | |
271 | smsg.msg_control = cred_msg; | |
272 | smsg.msg_controllen = sizeof(cred_msg); | |
273 | ||
274 | retval = recvmsg(sock, &smsg, 0); | |
53921bfa | 275 | if (retval < 0) { |
2f6cbd19 KS |
276 | if (errno != EINTR) |
277 | dbg("unable to receive message"); | |
278 | return; | |
53921bfa | 279 | } |
0028653c KS |
280 | cmsg = CMSG_FIRSTHDR(&smsg); |
281 | cred = (struct ucred *) CMSG_DATA(cmsg); | |
282 | ||
7b1cbec9 KS |
283 | if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) { |
284 | dbg("no sender credentials received, message ignored"); | |
285 | goto skip; | |
286 | } | |
287 | ||
0028653c KS |
288 | if (cred->uid != 0) { |
289 | dbg("sender uid=%i, message ignored", cred->uid); | |
7b1cbec9 | 290 | goto skip; |
0028653c KS |
291 | } |
292 | ||
53921bfa KS |
293 | if (strncmp(msg->magic, UDEV_MAGIC, sizeof(UDEV_MAGIC)) != 0 ) { |
294 | dbg("message magic '%s' doesn't match, ignore it", msg->magic); | |
7b1cbec9 | 295 | goto skip; |
53921bfa | 296 | } |
a695feae | 297 | |
86590cd5 | 298 | /* if no seqnum is given, we move straight to exec queue */ |
2f6cbd19 | 299 | if (msg->seqnum == -1) { |
86590cd5 | 300 | list_add(&msg->list, &exec_list); |
f27125f9 | 301 | run_exec_q = 1; |
86590cd5 | 302 | } else { |
86590cd5 | 303 | msg_queue_insert(msg); |
86590cd5 | 304 | } |
7b1cbec9 KS |
305 | return; |
306 | ||
307 | skip: | |
308 | free(msg); | |
309 | return; | |
a695feae | 310 | } |
1c5c245e | 311 | |
80775577 | 312 | asmlinkage static void sig_handler(int signum) |
7fafc032 | 313 | { |
f27125f9 | 314 | int rc; |
47bf9196 | 315 | |
53921bfa KS |
316 | switch (signum) { |
317 | case SIGINT: | |
318 | case SIGTERM: | |
53921bfa KS |
319 | exit(20 + signum); |
320 | break; | |
2f6cbd19 | 321 | case SIGALRM: |
f27125f9 | 322 | /* set flag, then write to pipe if needed */ |
323 | run_msg_q = 1; | |
324 | goto do_write; | |
2f6cbd19 KS |
325 | break; |
326 | case SIGCHLD: | |
f27125f9 | 327 | /* set flag, then write to pipe if needed */ |
2f6cbd19 | 328 | children_waiting = 1; |
f27125f9 | 329 | goto do_write; |
2f6cbd19 | 330 | break; |
53921bfa | 331 | default: |
47bf9196 | 332 | dbg("unhandled signal %d", signum); |
f27125f9 | 333 | return; |
334 | } | |
335 | ||
336 | do_write: | |
337 | /* if pipe is empty, write to pipe to force select to return | |
338 | * immediately when it gets called | |
339 | */ | |
340 | if (!sig_flag) { | |
341 | rc = write(pipefds[1],&signum,sizeof(signum)); | |
342 | if (rc < 0) | |
343 | dbg("unable to write to pipe"); | |
344 | else | |
345 | sig_flag = 1; | |
7fafc032 | 346 | } |
33db4b8d | 347 | } |
7fafc032 | 348 | |
2f6cbd19 KS |
349 | static void udev_done(int pid) |
350 | { | |
351 | /* find msg associated with pid and delete it */ | |
352 | struct hotplug_msg *msg; | |
353 | ||
354 | list_for_each_entry(msg, &running_list, list) { | |
355 | if (msg->pid == pid) { | |
3169e8d1 | 356 | dbg("<== exec seq %li came back", msg->seqnum); |
2f6cbd19 | 357 | run_queue_delete(msg); |
3169e8d1 | 358 | |
f27125f9 | 359 | /* we want to run the exec queue manager since there may |
360 | * be events waiting with the devpath of the one that | |
361 | * just finished | |
362 | */ | |
363 | run_exec_q = 1; | |
2f6cbd19 KS |
364 | return; |
365 | } | |
366 | } | |
367 | } | |
368 | ||
f27125f9 | 369 | static void reap_kids() |
370 | { | |
371 | /* reap all dead children */ | |
372 | while(1) { | |
373 | int pid = waitpid(-1, 0, WNOHANG); | |
374 | if ((pid == -1) || (pid == 0)) | |
375 | break; | |
376 | udev_done(pid); | |
377 | } | |
378 | } | |
379 | ||
380 | /* just read everything from the pipe and clear the flag, | |
381 | * the useful flags were set in the signal handler | |
382 | */ | |
383 | static void user_sighandler() | |
384 | { | |
385 | int sig; | |
386 | while(1) { | |
387 | int rc = read(pipefds[0],&sig,sizeof(sig)); | |
388 | if (rc < 0) | |
389 | break; | |
390 | ||
391 | sig_flag = 0; | |
392 | } | |
393 | } | |
394 | ||
395 | ||
33db4b8d KS |
396 | int main(int argc, char *argv[]) |
397 | { | |
f27125f9 | 398 | int ssock, maxsockplus; |
53921bfa | 399 | struct sockaddr_un saddr; |
1dadabd7 | 400 | socklen_t addrlen; |
53921bfa | 401 | int retval; |
0028653c | 402 | const int on = 1; |
f8911dbb | 403 | struct sigaction act; |
f27125f9 | 404 | fd_set readfds; |
53921bfa | 405 | |
95a6f4c8 | 406 | init_logging("udevd"); |
896e5aa9 | 407 | dbg("version %s", UDEV_VERSION); |
95a6f4c8 | 408 | |
7b1cbec9 KS |
409 | if (getuid() != 0) { |
410 | dbg("need to be root, exit"); | |
411 | exit(1); | |
412 | } | |
e5a2989e | 413 | |
f27125f9 | 414 | /* setup signal handler pipe */ |
e5a2989e KS |
415 | retval = pipe(pipefds); |
416 | if (retval < 0) { | |
417 | dbg("error getting pipes: %s", strerror(errno)); | |
418 | exit(1); | |
419 | } | |
420 | ||
421 | retval = fcntl(pipefds[0], F_SETFL, O_NONBLOCK); | |
422 | if (retval < 0) { | |
423 | dbg("error fcntl on read pipe: %s", strerror(errno)); | |
424 | exit(1); | |
425 | } | |
426 | ||
427 | retval = fcntl(pipefds[1], F_SETFL, O_NONBLOCK); | |
428 | if (retval < 0) { | |
429 | dbg("error fcntl on write pipe: %s", strerror(errno)); | |
430 | exit(1); | |
431 | } | |
f27125f9 | 432 | |
433 | /* set signal handlers */ | |
f8911dbb | 434 | act.sa_handler = sig_handler; |
f27125f9 | 435 | sigemptyset(&act.sa_mask); |
f8911dbb KS |
436 | act.sa_flags = SA_RESTART; |
437 | sigaction(SIGINT, &act, NULL); | |
438 | sigaction(SIGTERM, &act, NULL); | |
f8911dbb KS |
439 | sigaction(SIGALRM, &act, NULL); |
440 | sigaction(SIGCHLD, &act, NULL); | |
7fafc032 | 441 | |
53921bfa KS |
442 | memset(&saddr, 0x00, sizeof(saddr)); |
443 | saddr.sun_family = AF_LOCAL; | |
872344c4 KS |
444 | /* use abstract namespace for socket path */ |
445 | strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH); | |
1dadabd7 | 446 | addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1; |
53921bfa | 447 | |
2f6cbd19 | 448 | ssock = socket(AF_LOCAL, SOCK_DGRAM, 0); |
53921bfa | 449 | if (ssock == -1) { |
7b1cbec9 | 450 | dbg("error getting socket, exit"); |
53921bfa KS |
451 | exit(1); |
452 | } | |
453 | ||
2f6cbd19 | 454 | /* the bind takes care of ensuring only one copy running */ |
f8911dbb | 455 | retval = bind(ssock, (struct sockaddr *) &saddr, addrlen); |
53921bfa | 456 | if (retval < 0) { |
7b1cbec9 | 457 | dbg("bind failed, exit"); |
53921bfa KS |
458 | goto exit; |
459 | } | |
460 | ||
0028653c KS |
461 | /* enable receiving of the sender credentials */ |
462 | setsockopt(ssock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)); | |
7d855c31 KS |
463 | |
464 | /* possible override of udev binary, used for testing */ | |
465 | udev_bin = getenv("UDEV_BIN"); | |
466 | if (udev_bin != NULL) | |
467 | dbg("udev binary is set to '%s'", udev_bin); | |
468 | else | |
469 | udev_bin = UDEV_BIN; | |
0028653c | 470 | |
e5a2989e KS |
471 | FD_ZERO(&readfds); |
472 | FD_SET(ssock, &readfds); | |
473 | FD_SET(pipefds[0], &readfds); | |
f27125f9 | 474 | maxsockplus = ssock+1; |
2f6cbd19 | 475 | while (1) { |
f27125f9 | 476 | fd_set workreadfds = readfds; |
477 | retval = select(maxsockplus, &workreadfds, NULL, NULL, NULL); | |
e5a2989e | 478 | |
f27125f9 | 479 | if (retval < 0) { |
e5a2989e KS |
480 | if (errno != EINTR) |
481 | dbg("error in select: %s", strerror(errno)); | |
f27125f9 | 482 | continue; |
2f6cbd19 | 483 | } |
e5a2989e | 484 | |
f27125f9 | 485 | if (FD_ISSET(ssock, &workreadfds)) |
486 | handle_msg(ssock); | |
e5a2989e | 487 | |
f27125f9 | 488 | if (FD_ISSET(pipefds[0], &workreadfds)) |
489 | user_sighandler(); | |
e5a2989e | 490 | |
f27125f9 | 491 | if (children_waiting) { |
2f6cbd19 | 492 | children_waiting = 0; |
f27125f9 | 493 | reap_kids(); |
494 | } | |
e5a2989e | 495 | |
f27125f9 | 496 | if (run_msg_q) { |
497 | run_msg_q = 0; | |
498 | msg_queue_manager(); | |
499 | } | |
e5a2989e | 500 | |
f27125f9 | 501 | if (run_exec_q) { |
f27125f9 | 502 | /* this is tricky. exec_queue_manager() loops over exec_list, and |
503 | * calls running_with_devpath(), which loops over running_list. This gives | |
504 | * O(N*M), which can get *nasty*. Clean up running_list before | |
505 | * calling exec_queue_manager(). | |
506 | */ | |
f27125f9 | 507 | if (children_waiting) { |
508 | children_waiting = 0; | |
509 | reap_kids(); | |
2f6cbd19 | 510 | } |
f27125f9 | 511 | |
512 | run_exec_q = 0; | |
513 | exec_queue_manager(); | |
53921bfa | 514 | } |
53921bfa KS |
515 | } |
516 | exit: | |
517 | close(ssock); | |
53921bfa | 518 | exit(1); |
7fafc032 | 519 | } |