w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 68025ece18bb9acb4d63929a72698e69aeda982d
parent 475bf005755b81023bd4619248870897473f7591
Author: ukai <ukai>
Date:   Tue, 24 Sep 2002 17:35:52 +0000

[w3m-dev 03321] Bug#162104: file descriptors 1 and 2 are closed rather than reopened to /dev/null
* etc.c (mySystem): fd 0,1,2 redirect /dev/null, close all other fds
From: Fumitoshi UKAI  <ukai@debian.or.jp>

Diffstat:
MChangeLog | 5+++++
Metc.c | 9+++++++--
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +2002-09-25 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev 03321] Bug#162104: file descriptors 1 and 2 are closed rather than reopened to /dev/null + * etc.c (mySystem): fd 0,1,2 redirect /dev/null, close all other fds + 2002-09-25 AIDA Shinra <aida-s@jcom.home.ne.jp> * [w3m-dev 03319] mailto diff --git a/etc.c b/etc.c @@ -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); }