Di_exec

## Functions

int | di_exec_full (const char *path, const char *const argv[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
static int | di_exec (const char *path, const char *const argv[])
int | di_exec_env_full (const char *path, const char *const argv[], const char *const envp[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
static int | di_exec_env (const char *path, const char *const argv[], const char *const envp[])
int | di_exec_path_full (const char *file, const char *const argv[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
static int | di_exec_path (const char *file, const char *const argv[])
int | di_exec_shell_full (const char *const cmd, di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
static int | di_exec_shell (const char *const cmd)
static int | di_exec_shell_log (const char *const cmd)
int | di_exec_mangle_status (int status)
static int | di_execlog (const char *const cmd) __attribute__((deprecated))

## Variables

di_io_handler | di_exec_io_log
di_process_handler | di_exec_prepare_chdir
di_process_handler | di_exec_prepare_chroot

## Detailed Description

## Function Documentation

## di_exec()

static int di_exec | ( | const char * | path,
|  | const char *const | argv[]
| ) |  |

inline static

execv like call

Parameters

  path | executable with path
  argv | NULL-terminated area of char pointer

Returns
  status or error

{
return di_exec_full (path, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
di_exec_full
int di_exec_full(const char *path, const char *const argv[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
Definition: exec.c:227

References di_exec_full().

## di_exec_env()

static int di_exec_env | ( | const char * | path,
|  | const char *const | argv[],
|  | const char *const | envp[]
| ) |  |

inline static

execve like call

Parameters

  path | executable with path
  argv | NULL-terminated area of char pointer
  envp | NULL-terminated area of char pointer

Returns
  status or error

{
return di_exec_env_full (path, argv, envp, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
di_exec_env_full
int di_exec_env_full(const char *path, const char *const argv[], const char *const envp[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
Definition: exec.c:232

References di_exec_env_full().

## di_exec_env_full()

int di_exec_env_full | ( | const char * | path,
|  | const char *const | argv[],
|  | const char *const | envp[],
|  | di_io_handler * | stdout_handler,
|  | di_io_handler * | stderr_handler,
|  | void * | io_user_data,
|  | di_process_handler * | parent_prepare_handler,
|  | void * | parent_prepare_user_data,
|  | di_process_handler * | child_prepare_handler,
|  | void * | child_prepare_user_data
| ) |  |

execve like call

Parameters

  path | executable with path
  argv | NULL-terminated area of char pointer
  envp | NULL-terminated area of char pointer
  stdout_handler | di_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
  stderr_handler | di_io_handler which gets stderr
  io_user_data | user_data for di_io_handler
  parent_prepare_handler | di_process_handler which is called after the fork in the parent
  parent_prepare_user_data | user_data for parent_prepare_handler
  child_prepare_handler | di_process_handler which is called after the fork in the child
  child_prepare_user_data | user_data for child_prepare_handler

Returns
  status or error

{
return internal_di_exec (path, false, argv, envp, stdout_handler, stderr_handler, io_user_data, parent_prepare_handler, parent_prepare_user_data, child_prepare_handler, child_prepare_user_data);
}

Referenced by di_exec_env().

## di_exec_full()

int di_exec_full | ( | const char * | path,
|  | const char *const | argv[],
|  | di_io_handler * | stdout_handler,
|  | di_io_handler * | stderr_handler,
|  | void * | io_user_data,
|  | di_process_handler * | parent_prepare_handler,
|  | void * | parent_prepare_user_data,
|  | di_process_handler * | child_prepare_handler,
|  | void * | child_prepare_user_data
| ) |  |

execv like call

Parameters

  path | executable with path
  argv | NULL-terminated area of char pointer
  stdout_handler | di_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
  stderr_handler | di_io_handler which gets stderr
  io_user_data | user_data for di_io_handler
  parent_prepare_handler | di_process_handler which is called after the fork in the parent
  parent_prepare_user_data | user_data for parent_prepare_handler
  child_prepare_handler | di_process_handler which is called after the fork in the child
  child_prepare_user_data | user_data for child_prepare_handler

Returns
  status or error

{
return internal_di_exec (path, false, argv, NULL, stdout_handler, stderr_handler, io_user_data, parent_prepare_handler, parent_prepare_user_data, child_prepare_handler, child_prepare_user_data);
}

Referenced by di_exec().

## di_exec_mangle_status()

int di_exec_mangle_status | ( | int | status | ) |

mangle status like sh does it:

- if signaled: 128 + signal
- else return code

{
if (WIFEXITED (status))
return WEXITSTATUS (status);
if (WIFSIGNALED (status))
return 128 + WTERMSIG (status);
if (WIFSTOPPED (status))
return 128 + WSTOPSIG (status);
return status;
}

## di_exec_path()

static int di_exec_path | ( | const char * | file,
|  | const char *const | argv[]
| ) |  |

inline static

execvp like call

Parameters

  file | executable
  argv | NULL-terminated area of char pointer

Returns
  status or error

{
return di_exec_path_full (file, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
di_exec_path_full
int di_exec_path_full(const char *file, const char *const argv[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
Definition: exec.c:237

References di_exec_path_full().

## di_exec_path_full()

int di_exec_path_full | ( | const char * | file,
|  | const char *const | argv[],
|  | di_io_handler * | stdout_handler,
|  | di_io_handler * | stderr_handler,
|  | void * | io_user_data,
|  | di_process_handler * | parent_prepare_handler,
|  | void * | parent_prepare_user_data,
|  | di_process_handler * | child_prepare_handler,
|  | void * | child_prepare_user_data
| ) |  |

execvp like call

Parameters

  file | executable
  argv | NULL-terminated area of char pointer
  stdout_handler | di_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
  stderr_handler | di_io_handler which gets stderr
  io_user_data | user_data for di_io_handler
  parent_prepare_handler | di_process_handler which is called after the fork in the parent
  parent_prepare_user_data | user_data for parent_prepare_handler
  child_prepare_handler | di_process_handler which is called after the fork in the child
  child_prepare_user_data | user_data for child_prepare_handler

Returns
  status or error

{
return internal_di_exec (file, true, argv, NULL, stdout_handler, stderr_handler, io_user_data, parent_prepare_handler, parent_prepare_user_data, child_prepare_handler, child_prepare_user_data);
}

Referenced by di_exec_path().

## di_exec_shell()

static int di_exec_shell | ( | const char *const | cmd | ) |

inline static

system like call

Parameters

  cmd | command

Returns
  status or error

{
return di_exec_shell_full (cmd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
}
di_exec_shell_full
int di_exec_shell_full(const char *const cmd, di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data)
Definition: exec.c:242

References di_exec_shell_full().

## di_exec_shell_full()

int di_exec_shell_full | ( | const char *const | cmd,
|  | di_io_handler * | stdout_handler,
|  | di_io_handler * | stderr_handler,
|  | void * | io_user_data,
|  | di_process_handler * | parent_prepare_handler,
|  | void * | parent_prepare_user_data,
|  | di_process_handler * | child_prepare_handler,
|  | void * | child_prepare_user_data
| ) |  |

system like call

Parameters

  cmd | command
  stdout_handler | di_io_handler which gets stdout
  stderr_handler | di_io_handler which gets stderr
  io_user_data | user_data for di_io_handler
  parent_prepare_handler | di_process_handler which is called after the fork in the parent
  parent_prepare_user_data | user_data for parent_prepare_handler
  child_prepare_handler | di_process_handler which is called after the fork in the child
  child_prepare_user_data | user_data for child_prepare_handler

Returns
  status or error

{
const char *const argv[] = { "sh", "-c", cmd, NULL };
return internal_di_exec ("/bin/sh", false, argv, NULL, stdout_handler, stderr_handler, io_user_data, parent_prepare_handler, parent_prepare_user_data, child_prepare_handler, child_prepare_user_data);
}

Referenced by di_exec_shell(), and di_exec_shell_log().

## di_exec_shell_log()

static int di_exec_shell_log | ( | const char *const | cmd | ) |

inline static

system like call with output via log

Parameters

  cmd | command

Returns
  status or error

{
return di_exec_shell_full (cmd, di_exec_io_log, NULL, NULL, NULL, NULL, NULL, NULL);
}
di_exec_io_log
di_io_handler di_exec_io_log
Definition: exec.h:38

References di_exec_io_log, and di_exec_shell_full().

Referenced by di_execlog().

## di_execlog()

static int di_execlog | ( | const char *const | cmd | ) |

inline static

Deprecated:
  Alias of di_exec_shell_log

{
return di_exec_shell_log (cmd);
}
di_exec_shell_log
static int di_exec_shell_log(const char *const cmd)
Definition: exec.h:180

References di_exec_shell_log().

## Variable Documentation

## di_exec_io_log

di_io_handler di_exec_io_log

logs the output

Referenced by di_exec_shell_log().

## di_exec_prepare_chdir

di_process_handler di_exec_prepare_chdir

chdir to user_data

Parameters

  user_data | path

## di_exec_prepare_chroot

di_process_handler di_exec_prepare_chroot

chroot to user_data

Parameters

  user_data | path