aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-02 07:33:26 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-02 10:15:36 +0200
commit7e61b3de06a190aa9e84b3fc0070ee27e57770d1 (patch)
treef7abcb721a0e0fed838e06643909330684d6a84d /src
parent6e2b00096dcf2733b58e82cda3510ed638983a20 (diff)
downloadcalcurse-7e61b3de06a190aa9e84b3fc0070ee27e57770d1.tar.gz
calcurse-7e61b3de06a190aa9e84b3fc0070ee27e57770d1.zip
Add child_wait() function
Can be used to wait for the termination of a child process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h1
-rw-r--r--src/utils.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index cb9ea93..dec14c4 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -880,6 +880,7 @@ void str_toupper (char *);
void file_close (FILE *, const char *);
void psleep (unsigned);
int fork_exec (int *, int *, const char *, char *const *);
+int child_wait (int *, int *, int);
/* vars.c */
extern int col, row;
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 <sys/types.h>
#include <errno.h>
#include <fcntl.h>
+#include <sys/wait.h>
#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;
+}