Changeset fc625fb for functions.c


Ignore:
Timestamp:
Jun 22, 2011, 3:45:52 PM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
b343c2c (diff), 6376af1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 6376af1d0990d3324261fd650a8d36af1195eacf into b343c2c1248ccfcd8b514c26f4c896c1ec41888b
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rb343c2c rfc625fb  
    31563156    }
    31573157   
    3158     /* if it exited, fork & exec a new one */
     3158    /* if it exited, spawn a new one */
    31593159    if (owl_global_get_newmsgproc_pid(&g)==0) {
    3160       pid_t i;
    31613160      int myargc;
    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);
     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        }
    31863180      }
     3181      g_strfreev(argv);
    31873182    }
    31883183  }
Note: See TracChangeset for help on using the changeset viewer.