# HG changeset patch # User Andreas Schwab # Date 1278841784 -7200 # Node ID b7a866c9460c4153edcc68394a6c7792286f7cf0 # Parent e856a274549b05cedbe13b7513a5fd5eac5676b1 * callproc.c (relocate_fd): Use F_DUPFD if defined. diff -r e856a274549b -r b7a866c9460c src/ChangeLog --- a/src/ChangeLog Sun Jul 11 11:27:13 2010 +0200 +++ b/src/ChangeLog Sun Jul 11 11:49:44 2010 +0200 @@ -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 -r e856a274549b -r b7a866c9460c src/callproc.c --- a/src/callproc.c Sun Jul 11 11:27:13 2010 +0200 +++ b/src/callproc.c Sun Jul 11 11:49:44 2010 +0200 @@ -1288,7 +1288,16 @@ 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 @@ 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; }