From 12f146c032eb21c73f9a941ce812876a23e625f0 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 20 Feb 2003 19:11:18 +0000 Subject: Redirect program's stdout and stderr to /dev/null 2003-02-20 Jeffrey Stedfast * camel-filter-search.c (run_command): Redirect program's stdout and stderr to /dev/null * camel-filter-driver.c (pipe_to_system): Redirect the program's stderr to /dev/null (pipe_to_system): Write the pipe to a mem stream and use the mem stream in the parser. Also, when setting an exception get the errno from the parser so we can give more info about the error to the user. svn path=/trunk/; revision=19974 --- camel/camel-filter-search.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'camel/camel-filter-search.c') diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c index 9a42b5e002..e0e385346b 100644 --- a/camel/camel-filter-search.c +++ b/camel/camel-filter-search.c @@ -519,18 +519,22 @@ run_command (struct _ESExp *f, int argc, struct _ESExpResult **argv, FilterMessa if (!(pid = fork ())) { /* child process */ GPtrArray *args; - int maxfd, i; + int maxfd, fd, i; - if (dup2 (in_fds[0], STDIN_FILENO) < 0) + fd = open ("/dev/null", O_WRONLY); + + if (dup2 (in_fds[0], STDIN_FILENO) < 0 || + dup2 (fd, STDOUT_FILENO) < 0 || + dup2 (fd, STDERR_FILENO) < 0) _exit (255); setsid (); maxfd = sysconf (_SC_OPEN_MAX); if (maxfd > 0) { - for (i = 0; i < maxfd; i++) { - if (i != STDIN_FILENO && i != STDOUT_FILENO && i != STDERR_FILENO) - close (i); + for (fd = 0; fd < maxfd; fd++) { + if (fd != STDIN_FILENO && fd != STDOUT_FILENO && fd != STDERR_FILENO) + close (fd); } } -- cgit v1.2.3