Changeset 6376af1
- Timestamp:
- Jun 3, 2011, 11:07:50 PM (14 years ago)
- Children:
- fc625fb
- Parents:
- cc305b5
- git-author:
- David Benjamin <davidben@mit.edu> (06/03/11 22:58:53)
- git-committer:
- David Benjamin <davidben@mit.edu> (06/03/11 23:07:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r259e60a8 r6376af1 3183 3183 } 3184 3184 3185 /* if it exited, fork & execa new one */3185 /* if it exited, spawn a new one */ 3186 3186 if (owl_global_get_newmsgproc_pid(&g)==0) { 3187 pid_t i;3188 3187 int myargc; 3189 i=fork(); 3190 if (i) { 3191 /* parent set the child's pid */ 3192 owl_global_set_newmsgproc_pid(&g, i); 3193 owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i); 3194 } else { 3195 /* child exec's the program */ 3196 char **parsed; 3197 parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc); 3198 if (myargc < 0) { 3199 owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", owl_global_get_newmsgproc(&g)); 3200 } 3201 if (myargc <= 0) { 3202 _exit(127); 3203 } 3204 owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc); 3205 3206 execvp(parsed[0], parsed); 3207 3208 3209 /* was there an error exec'ing? */ 3210 owl_function_debugmsg("Cannot run newmsgproc '%s': cannot exec '%s': %s", 3211 owl_global_get_newmsgproc(&g), parsed[0], strerror(errno)); 3212 _exit(127); 3188 char **argv = owl_parseline(owl_global_get_newmsgproc(&g), &myargc); 3189 if (myargc < 0) { 3190 owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", 3191 owl_global_get_newmsgproc(&g)); 3192 } else if (myargc > 0) { 3193 /* Spawn the child. */ 3194 pid_t pid; 3195 GError *error = NULL; 3196 owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc); 3197 if (g_spawn_async(NULL, argv, NULL, 3198 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, 3199 NULL, NULL, &pid, &error)) { 3200 owl_global_set_newmsgproc_pid(&g, pid); 3201 owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", pid); 3202 } else { 3203 owl_function_debugmsg("Cannot run newmsgproc '%s': %s", 3204 owl_global_get_newmsgproc(&g), error->message); 3205 g_error_free(error); 3206 } 3213 3207 } 3208 g_strfreev(argv); 3214 3209 } 3215 3210 }
Note: See TracChangeset
for help on using the changeset viewer.