paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Functions
exec.c File Reference

Helper functions for spawning new processes. More...

#include <regex.h>
#include "para.h"
#include "error.h"
#include "fd.h"
#include "string.h"

Functions

int para_exec_cmdline_pid (pid_t *pid, const char *cmdline, int *fds)
 Exec the given command. More...
 

Detailed Description

Helper functions for spawning new processes.

Function Documentation

◆ para_exec_cmdline_pid()

int para_exec_cmdline_pid ( pid_t *  pid,
const char *  cmdline,
int *  fds 
)

Exec the given command.

Parameters
pidWill hold the pid of the created process upon return.
cmdlineHolds the command and its arguments, separated by spaces.
fdsA pointer to a value-result array.

This function uses fork/exec to create a new process. fds must be a pointer to three integers, corresponding to stdin, stdout and stderr respectively. It specifies how to deal with fd 0, 1, 2 in the child. The contents of fds are interpreted as follows:

 - fd[i] < 0: leave fd \a i alone.
 - fd[i] = 0: dup fd \a i to \p /dev/null.
 - fd[i] > 0: create a pipe and dup i to one end of that pipe.
 Upon return, fd[i] contains the file descriptor of the pipe.

    In any case, all unneeded file descriptors are closed.
Returns
Standard.

References create_argv().