Exemple #1
0
int fw_perform( gchar *action, GHashTable *conf, peer *p ) {
    fw_action *act = g_new( fw_action, 1 );
    pid_t pid;

    act->cmd = action;
    act->p   = p;

    pid = fork();
    if (pid == -1)
	g_error( "Can't fork: %m" );
    
    if (! pid)
	fw_exec( act, conf );

    act->pid    = pid;
    g_idle_add( (GSourceFunc) fw_cleanup, act );
    return 0;
}
Exemple #2
0
// timeout = 0 , do not wait
int fw_perform_exec( gchar *action, GHashTable *conf, peer *p, gboolean wait ) {
    
    fw_action *act = g_new( fw_action, 1 );
    pid_t pid;
    
    act->cmd = action;
    act->p   = p;
    
    pid = fork();
    if (pid == -1)
        g_error( "Can't fork: %m" );
    
    if (! pid)
        fw_exec( act, conf );
    
    act->pid = pid;
    if ( !wait ) {
        g_idle_add( (GSourceFunc) fw_cleanup, act );
    } else {
        while(fw_wait(act));
    }
    return 0;
}