libdebian-installer
Functions | Variables
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

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

execv like call

Parameters
pathexecutable with path
argvNULL-terminated area of char pointer
Returns
status or error

References di_exec_env_full(), and di_exec_full().

79 {
80  return di_exec_full (path, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
81 }
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:226
static int di_exec_env ( const char *  path,
const char *const  argv[],
const char *const  envp[] 
)
inlinestatic

execve like call

Parameters
pathexecutable with path
argvNULL-terminated area of char pointer
envpNULL-terminated area of char pointer
Returns
status or error

References di_exec_env_full(), and di_exec_path_full().

111 {
112  return di_exec_env_full (path, argv, envp, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
113 }
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:231
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
pathexecutable with path
argvNULL-terminated area of char pointer
envpNULL-terminated area of char pointer
stdout_handlerdi_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
stderr_handlerdi_io_handler which gets stderr
io_user_datauser_data for di_io_handler
parent_prepare_handlerdi_process_handler which is called after the fork in the parent
parent_prepare_user_datauser_data for parent_prepare_handler
child_prepare_handlerdi_process_handler which is called after the fork in the child
child_prepare_user_datauser_data for child_prepare_handler
Returns
status or error

Referenced by di_exec(), and di_exec_env().

232 {
233  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);
234 }
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
pathexecutable with path
argvNULL-terminated area of char pointer
stdout_handlerdi_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
stderr_handlerdi_io_handler which gets stderr
io_user_datauser_data for di_io_handler
parent_prepare_handlerdi_process_handler which is called after the fork in the parent
parent_prepare_user_datauser_data for parent_prepare_handler
child_prepare_handlerdi_process_handler which is called after the fork in the child
child_prepare_user_datauser_data for child_prepare_handler
Returns
status or error

Referenced by di_exec().

227 {
228  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);
229 }
int di_exec_mangle_status ( int  status)

mangle status like sh does it:

  • if signaled: 128 + signal
  • else return code

Referenced by di_exec_shell_log().

272 {
273  if (WIFEXITED (status))
274  return WEXITSTATUS (status);
275  if (WIFSIGNALED (status))
276  return 128 + WTERMSIG (status);
277  if (WIFSTOPPED (status))
278  return 128 + WSTOPSIG (status);
279  return status;
280 }
static int di_exec_path ( const char *  file,
const char *const  argv[] 
)
inlinestatic

execvp like call

Parameters
fileexecutable
argvNULL-terminated area of char pointer
Returns
status or error

References di_exec_path_full(), and di_exec_shell_full().

141 {
142  return di_exec_path_full (file, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
143 }
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:236
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
fileexecutable
argvNULL-terminated area of char pointer
stdout_handlerdi_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
stderr_handlerdi_io_handler which gets stderr
io_user_datauser_data for di_io_handler
parent_prepare_handlerdi_process_handler which is called after the fork in the parent
parent_prepare_user_datauser_data for parent_prepare_handler
child_prepare_handlerdi_process_handler which is called after the fork in the child
child_prepare_user_datauser_data for child_prepare_handler
Returns
status or error

Referenced by di_exec_env(), and di_exec_path().

237 {
238  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);
239 }
static int di_exec_shell ( const char *const  cmd)
inlinestatic

system like call

Parameters
cmdcommand
Returns
status or error

References di_exec_shell_full().

169 {
170  return di_exec_shell_full (cmd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
171 }
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:241
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
cmdcommand
stdout_handlerdi_io_handler which gets stdout
stderr_handlerdi_io_handler which gets stderr
io_user_datauser_data for di_io_handler
parent_prepare_handlerdi_process_handler which is called after the fork in the parent
parent_prepare_user_datauser_data for parent_prepare_handler
child_prepare_handlerdi_process_handler which is called after the fork in the child
child_prepare_user_datauser_data for child_prepare_handler
Returns
status or error

References di_exec_io_log, di_exec_prepare_chdir, di_exec_prepare_chroot, di_log(), and DI_LOG_LEVEL_OUTPUT.

Referenced by di_exec_path(), di_exec_shell(), and di_exec_shell_log().

242 {
243  const char *const argv[] = { "sh", "-c", cmd, NULL };
244  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);
245 }
static int di_exec_shell_log ( const char *const  cmd)
inlinestatic

system like call with output via log

Parameters
cmdcommand
Returns
status or error

References di_exec_io_log, di_exec_mangle_status(), di_exec_shell_full(), and di_execlog().

Referenced by di_execlog().

181 {
182  return di_exec_shell_full (cmd, di_exec_io_log, NULL, NULL, NULL, NULL, NULL, NULL);
183 }
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:241
di_io_handler di_exec_io_log
Definition: exec.h:38
static int di_execlog ( const char *const  cmd)
inlinestatic
Deprecated:
Alias of di_exec_shell_log

References di_exec_shell_log().

Referenced by di_exec_shell_log().

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

Variable Documentation

di_io_handler di_exec_io_log

logs the output

Referenced by di_exec_shell_full(), and di_exec_shell_log().

di_process_handler di_exec_prepare_chdir

chdir to user_data

Parameters
user_datapath

Referenced by di_exec_shell_full().

di_process_handler di_exec_prepare_chroot

chroot to user_data

Parameters
user_datapath

Referenced by di_exec_shell_full().