aboutsummaryrefslogtreecommitdiff
path: root/src/preproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/preproc.c')
-rw-r--r--src/preproc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/preproc.c b/src/preproc.c
index f1d5227..ce32a29 100644
--- a/src/preproc.c
+++ b/src/preproc.c
@@ -664,13 +664,18 @@ grecs_preproc_extrn_start(const char *file_name, pid_t *ppid)
/*FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", ppcmd);*/
- pipe(pout);
+ if (pipe(pout)) {
+ grecs_error(NULL, errno, "pipe");
+ return NULL;
+ }
switch (pid = fork()) {
/* The child branch. */
case 0:
if (pout[1] != 1) {
- close(1);
- dup2(pout[1], 1);
+ if (dup2(pout[1], 1) == -1) {
+ grecs_error(NULL, errno, "dup2");
+ exit(127);
+ }
}
/* Close unneeded descripitors */
@@ -684,13 +689,16 @@ grecs_preproc_extrn_start(const char *file_name, pid_t *ppid)
FILE *fp;
signal(SIGCHLD, SIG_DFL);
- pipe(p);
+ if (pipe(p)) {
+ grecs_error(NULL, errno, "pipe");
+ exit(127);
+ }
switch (pid = fork()) {
/* Grandchild */
case 0:
- if (p[1] != 2) {
- close(2);
- dup2(p[1], 2);
+ if (p[1] != 2 && dup2(p[1], 2) == -1) {
+ grecs_error(NULL, errno, "dup2");
+ exit(127);
}
close(p[0]);

Return to:

Send suggestions and report system problems to the System administrator.