diff options
Diffstat (limited to 'common/exechelp-posix.c')
-rw-r--r-- | common/exechelp-posix.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c index aaf628715..1f4cca6c8 100644 --- a/common/exechelp-posix.c +++ b/common/exechelp-posix.c @@ -313,11 +313,22 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], *statusfile = NULL; *pid = (pid_t)(-1); - es_fflush (infile); - es_rewind (infile); - fd = es_fileno (infile); - fdout = es_fileno (outfile); - if (fd == -1 || fdout == -1) + + if (infile) + { + es_fflush (infile); + es_rewind (infile); + fd = es_fileno (infile); + } + else + fd = -1; + + if (outfile) + fdout = es_fileno (outfile); + else + fdout = -1; + + if ((infile && fd == -1) || (outfile && fdout == -1)) log_fatal ("no file descriptor for file passed to gnupg_spawn_process\n"); if (pipe (rp) == -1) |