From: Andreas Schwab Date: Sun, 11 Jul 2010 09:49:44 +0000 (+0200) Subject: * callproc.c (relocate_fd): Use F_DUPFD if defined. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~51^2~78^2~7 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cf237e277f6b033fd8d47ecdc466722c73de5d96;p=emacs.git * callproc.c (relocate_fd): Use F_DUPFD if defined. --- diff --git a/src/ChangeLog b/src/ChangeLog index d6002ad2b20..6907c5add4c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2010-07-11 Andreas Schwab + * callproc.c (relocate_fd): Use F_DUPFD if defined. + * alloc.c (pending_malloc_warning, malloc_warning): Add const. * callproc.c (relocate_fd, getenv_internal_1, getenv_internal) (egetenv): Likewise. diff --git a/src/callproc.c b/src/callproc.c index e78d1a9aeaa..4ad6bcf41ea 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1288,7 +1288,16 @@ relocate_fd (int fd, int minfd) return fd; else { - int new = dup (fd); + int new; +#ifdef F_DUPFD + new = fcntl (fd, F_DUPFD, minfd); +#else + new = dup (fd); + if (new != -1) + /* Note that we hold the original FD open while we recurse, + to guarantee we'll get a new FD if we need it. */ + new = relocate_fd (new, minfd); +#endif if (new == -1) { const char *message1 = "Error while setting up child: "; @@ -1299,9 +1308,6 @@ relocate_fd (int fd, int minfd) emacs_write (2, message2, strlen (message2)); _exit (1); } - /* Note that we hold the original FD open while we recurse, - to guarantee we'll get a new FD if we need it. */ - new = relocate_fd (new, minfd); emacs_close (fd); return new; }