diff options
Diffstat (limited to 'etc.c')
-rw-r--r-- | etc.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.23 2002/09/24 16:35:02 ukai Exp $ */ +/* $Id: etc.c,v 1.24 2002/09/24 17:35:52 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -1208,11 +1208,16 @@ mySystem(char *command, int background) int pid; flush_tty(); if ((pid = fork()) == 0) { + int fd, i; reset_signals(); SETPGRP(); close_tty(); - fclose(stdout); - fclose(stderr); + dup2(open("/dev/null", O_RDONLY), 0); + dup2(open("/dev/null", O_WRONLY), 1); + dup2(fd = open("/dev/null", O_WRONLY), 2); + /* close all other file descriptors (socket, ...) */ + for (i = 3; i <= fd; i++) + close(i); execl("/bin/sh", "sh", "-c", command, NULL); exit(127); } |