aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-filter-search.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-02-21 03:11:18 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-02-21 03:11:18 +0800
commit12f146c032eb21c73f9a941ce812876a23e625f0 (patch)
treeffff3558f1021dd4674bd38bdf2b2bf54531da21 /camel/camel-filter-search.c
parent99a343eb815c833f54866d88bb222fa79947232c (diff)
downloadgsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar.gz
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar.bz2
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar.lz
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar.xz
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.tar.zst
gsoc2013-evolution-12f146c032eb21c73f9a941ce812876a23e625f0.zip
Redirect program's stdout and stderr to /dev/null
2003-02-20 Jeffrey Stedfast <fejj@ximian.com> * 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
Diffstat (limited to 'camel/camel-filter-search.c')
-rw-r--r--camel/camel-filter-search.c14
1 files changed, 9 insertions, 5 deletions
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);
}
}