Add child_wait() function
Can be used to wait for the termination of a child process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
6e2b00096d
commit
7e61b3de06
@ -880,6 +880,7 @@ void str_toupper (char *);
|
|||||||
void file_close (FILE *, const char *);
|
void file_close (FILE *, const char *);
|
||||||
void psleep (unsigned);
|
void psleep (unsigned);
|
||||||
int fork_exec (int *, int *, const char *, char *const *);
|
int fork_exec (int *, int *, const char *, char *const *);
|
||||||
|
int child_wait (int *, int *, int);
|
||||||
|
|
||||||
/* vars.c */
|
/* vars.c */
|
||||||
extern int col, row;
|
extern int col, row;
|
||||||
|
16
src/utils.c
16
src/utils.c
@ -43,6 +43,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include "calcurse.h"
|
#include "calcurse.h"
|
||||||
|
|
||||||
@ -789,3 +790,18 @@ fork_exec (int *pfdin, int *pfdout, const char *path, char *const *arg)
|
|||||||
}
|
}
|
||||||
return pid;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user