Changes in / [fc625fb:b343c2c]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rb343c2c rb343c2c  
    31563156    }
    31573157   
    3158     /* if it exited, spawn a new one */
     3158    /* if it exited, fork & exec a new one */
    31593159    if (owl_global_get_newmsgproc_pid(&g)==0) {
     3160      pid_t i;
    31603161      int myargc;
    3161       char **argv = owl_parseline(owl_global_get_newmsgproc(&g), &myargc);
    3162       if (myargc < 0) {
    3163         owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?",
    3164                               owl_global_get_newmsgproc(&g));
    3165       } else if (myargc > 0) {
    3166         /* Spawn the child. */
    3167         pid_t pid;
    3168         GError *error = NULL;
    3169         owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc);
    3170         if (g_spawn_async(NULL, argv, NULL,
    3171                           G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
    3172                           NULL, NULL, &pid, &error)) {
    3173           owl_global_set_newmsgproc_pid(&g, pid);
    3174           owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", pid);
    3175         } else {
    3176           owl_function_debugmsg("Cannot run newmsgproc '%s': %s",
    3177                                 owl_global_get_newmsgproc(&g), error->message);
    3178           g_error_free(error);
    3179         }
     3162      i=fork();
     3163      if (i) {
     3164        /* parent set the child's pid */
     3165        owl_global_set_newmsgproc_pid(&g, i);
     3166        owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i);
     3167      } else {
     3168        /* child exec's the program */
     3169        char **parsed;
     3170        parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc);
     3171        if (myargc < 0) {
     3172          owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", owl_global_get_newmsgproc(&g));
     3173        }
     3174        if (myargc <= 0) {
     3175          _exit(127);
     3176        }
     3177        owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc);
     3178       
     3179        execvp(parsed[0], parsed);
     3180       
     3181       
     3182        /* was there an error exec'ing? */
     3183        owl_function_debugmsg("Cannot run newmsgproc '%s': cannot exec '%s': %s",
     3184                              owl_global_get_newmsgproc(&g), parsed[0], strerror(errno));
     3185        _exit(127);
    31803186      }
    3181       g_strfreev(argv);
    31823187    }
    31833188  }
Note: See TracChangeset for help on using the changeset viewer.