Replace system_command_* and run_command_* APIs with simpler spawn() 09/189809/26
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 7 Nov 2018 11:04:34 +0000 (12:04 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 28 Feb 2019 11:12:30 +0000 (12:12 +0100)
commitdad0a556256a411b760104327c45a5ccd1a1b3eb
treee6ff2a6e9342ee782f8849766b97a2ea25995f99
parent7468269cc9e230683bc7cbaf9cf1a6ed4807ccf1
Replace system_command_* and run_command_* APIs with simpler spawn()

This commit introduces following utility functions to handle
external process execution:

 - spawn() - forks parent and executes specified command via execve(),
   establishes pipe between child and parent to monitor child lifetime.

   Ability to customize child environment is provided by the means of
   callbacks - spawn_{setstdout{,err},chdir,umask} are provided to set
   fds, chdir, and umask respectively.

 - wait_for_pid() - waitpid() for child, returning its exit code

 - spawn_wait() - combines both of above and adds ability to optionally
   specify timeout after which child is killed. Returns childs exit
   code (as wait_for_pid()), or -1 when timed out.

Change-Id: I55d1e4ae8f547be3883c43132a0e083b91f730e3
src/crash-manager/CMakeLists.txt
src/crash-manager/crash-manager.c
src/dump_systemstate/CMakeLists.txt
src/dump_systemstate/dump_systemstate.c
src/shared/spawn.c [new file with mode: 0644]
src/shared/spawn.h [new file with mode: 0644]
src/shared/util.c
src/shared/util.h