- Timestamp:
- Feb 9, 2003, 10:08:38 PM (22 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 7e3e00a
- Parents:
- ddb8252
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
ra15a84f r8f44c6b 22 22 #include <sys/param.h> 23 23 #include <sys/types.h> 24 #include <sys/wait.h>25 #include <errno.h>26 24 #include "owl.h" 27 25 … … 331 329 make it active */ 332 330 if (newzephyrs) { 333 if (owl_global_get_newmsgproc(&g) && strcmp(owl_global_get_newmsgproc(&g), "")) { 334 /* if there's a process out there, we need to check on it */ 335 if (owl_global_get_newmsgproc_pid(&g)) { 336 owl_function_debugmsg("Checking on newmsgproc pid==%i", owl_global_get_newmsgproc_pid(&g)); 337 owl_function_debugmsg("Waitpid return is %i", waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG)); 338 waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG); 339 if (waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG)==-1) { 340 /* it exited */ 341 owl_global_set_newmsgproc_pid(&g, 0); 342 owl_function_debugmsg("newmsgproc exited"); 343 } else { 344 owl_function_debugmsg("newmsgproc did not exit"); 345 } 346 } 347 348 /* if it exited, fork & exec a new one */ 349 if (owl_global_get_newmsgproc_pid(&g)==0) { 350 int i, myargc; 351 i=fork(); 352 if (i) { 353 /* parent set the child's pid */ 354 owl_global_set_newmsgproc_pid(&g, i); 355 waitpid(i, NULL, WNOHANG); 356 owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i); 357 } else { 358 /* child exec's the program */ 359 char **parsed; 360 parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc); 361 parsed=realloc(parsed, strlen(owl_global_get_newmsgproc(&g)+300)); 362 parsed[myargc]=(char *) NULL; 363 364 owl_function_debugmsg("About to exec: %s with %i arguments", parsed[0], myargc); 365 366 execvp(parsed[0], (char **) parsed); 367 368 369 /* was there an error exec'ing? */ 370 owl_function_debugmsg("Error execing: %s", strerror(errno)); 371 _exit(127); 372 } 373 } 374 } 331 owl_function_do_newmsgproc(); 375 332 } 376 333
Note: See TracChangeset
for help on using the changeset viewer.