コード例 #1
0
ファイル: superexec.c プロジェクト: mcruse/monotone
/*
 *  safe_fork_and_exec
 *
 *  Execute the specified file, preserving the current process.
 *  (Currently unused)
 *
 *  Parameters:
 *    pFilePath   - string specifying the file to execute
 *    argv        - the argument vector passed to new process;
 *                  the first argument should be the command name.
 *
 *  Returns:
 *    Returns 0 to the parent process.
 *    Does not return to the child process unless an error occurs,
 *    in which case 255 is returned.
 */
static
int safe_fork_and_exec( const char* pFilePath, char* const argv[] )
{
    pid_t child = fork();
    if (child)
    {
        /* Here if parent. */
        return 0;
    }
    
    /* Here if child. */
    return safe_exec( pFilePath, argv );
}
コード例 #2
0
ファイル: superexec.c プロジェクト: mcruse/monotone
/*
 *  main
 *
 *  Execute the specified file, with all signals unblocked.
 *  The command lien format is:
 *
 *    superexec file-path arg1 arg2 ... argN
 *
 *  Returns:
 *    The exit status of the executed program,
 *    255 if the program could not be launched, or if no program was specified.
 */
int main( int argc, char* argv[] )
{
	int err;
    if (argc > 1)
    {
        err = safe_exec( argv[1], &argv[1] );
        if (err)
        {
        	printf( "Error: unable to execute %s\n", argv[1] );
        	return err;
        }
    }
        
    printf( "Error: no program specified.\n" );
    return 255;
}
コード例 #3
0
ファイル: audispd.c プロジェクト: EricMCornelius/audit-cef
static int start_one_plugin(lnode *conf)
{
	if (conf->p->restart_cnt > daemon_config.max_restarts)
		return 1;

	if (conf->p->type == S_BUILTIN)
		start_builtin(conf->p);
	else if (conf->p->type == S_ALWAYS) {
		if (safe_exec(conf->p)) {
			syslog(LOG_ERR,
				"Error running %s (%s) continuing without it",
				conf->p->path, strerror(errno));
			conf->p->active = A_NO;
			return 0;
		}

		/* Close the parent's read side */
		close(conf->p->plug_pipe[0]);
		conf->p->plug_pipe[0] = -1;
		/* Avoid leaking descriptor */
		fcntl(conf->p->plug_pipe[1], F_SETFD, FD_CLOEXEC);
	}
	return 1;
}