From 7e61b3de06a190aa9e84b3fc0070ee27e57770d1 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 2 Jul 2011 07:33:26 +0200 Subject: Add child_wait() function Can be used to wait for the termination of a child process. Signed-off-by: Lukas Fleischer --- src/utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 61c87a1..75e702b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "calcurse.h" @@ -789,3 +790,18 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg) } return pid; } + +/* Wait for a child process to terminate. */ +int +child_wait (int *pfdin, int *pfdout, int pid) +{ + int stat; + + if (pfdin) + close (*pfdin); + if (pfdout) + close (*pfdout); + + waitpid (pid, &stat, 0); + return stat; +} -- cgit v1.2.3-54-g00ecf