summaryrefslogtreecommitdiff
path: root/src/basic/exec-util.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-01-22 15:22:37 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-20 18:49:13 -0500
commitc6e47247a745f9245eb3dbfb29fc066ef72d3886 (patch)
tree4bc9451abde3c562a24ae18c2bfcb2dee4f618c2 /src/basic/exec-util.h
parent504afd7c34e00eb84589e94e59cd14f2fffa2807 (diff)
downloadsystemd-c6e47247a745f9245eb3dbfb29fc066ef72d3886.tar.gz
basic/exec-util: add support for synchronous (ordered) execution
The output of processes can be gathered, and passed back to the callee. (This commit just implements the basic functionality and tests.) After the preparation in previous commits, the change in functionality is relatively simple. For coding convenience, alarm is prepared *before* any children are executed, and not before. This shouldn't matter usually, since just forking of the children should be pretty quick. One could also argue that this is more correct, because we will also catch the case when (for whatever reason), forking itself is slow. Three callback functions and three levels of serialization are used: - from individual generator processes to the generator forker - from the forker back to the main process - deserialization in the main process v2: - replace an structure with an indexed array of callbacks
Diffstat (limited to 'src/basic/exec-util.h')
-rw-r--r--src/basic/exec-util.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/basic/exec-util.h b/src/basic/exec-util.h
index 9f8daa9fc8..2c58e4bd5c 100644
--- a/src/basic/exec-util.h
+++ b/src/basic/exec-util.h
@@ -17,6 +17,22 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <stdbool.h>
+
#include "time-util.h"
-void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
+typedef int (*gather_stdout_callback_t) (int fd, void *arg);
+
+enum {
+ STDOUT_GENERATE, /* from generators to helper process */
+ STDOUT_COLLECT, /* from helper process to main process */
+ STDOUT_CONSUME, /* process data in main process */
+ _STDOUT_CONSUME_MAX,
+};
+
+int execute_directories(
+ const char* const* directories,
+ usec_t timeout,
+ gather_stdout_callback_t const callbacks[_STDOUT_CONSUME_MAX],
+ void* const callback_args[_STDOUT_CONSUME_MAX],
+ char *argv[]);