diff options
Diffstat (limited to 'libmailutils/stream/prog_stream.c')
-rw-r--r-- | libmailutils/stream/prog_stream.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libmailutils/stream/prog_stream.c b/libmailutils/stream/prog_stream.c index 14afa432e..206e14b4a 100644 --- a/libmailutils/stream/prog_stream.c +++ b/libmailutils/stream/prog_stream.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2009-2019 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -168,9 +168,15 @@ start_program_filter (int *p, struct _mu_prog_stream *fs, int flags) int rc = 0; if (REDIRECT_STDIN_P (flags)) - pipe (leftp); + { + if (pipe (leftp)) + return errno; + } if (REDIRECT_STDOUT_P (flags)) - pipe (rightp); + { + if (pipe (rightp)) + return errno; + } switch (fs->pid = fork ()) { @@ -251,9 +257,8 @@ start_program_filter (int *p, struct _mu_prog_stream *fs, int flags) } } - /* Close unneded descripitors */ - for (i = mu_getmaxfd (); i > 2; i--) - close (i); + /* Close unneeded descriptors */ + mu_close_fds (3); /*FIXME: Switch to other uid/gid if desired */ execvp (fs->progname, fs->argv); |