diff options
| author | Andreas Schwab | 2010-07-11 11:49:44 +0200 |
|---|---|---|
| committer | Andreas Schwab | 2010-07-11 11:49:44 +0200 |
| commit | cf237e277f6b033fd8d47ecdc466722c73de5d96 (patch) | |
| tree | aa015ae22b6639c2a212936fcafdd108f4f66299 /src/callproc.c | |
| parent | a8fe7202b4d4b86cdc66997dc624a367631abd51 (diff) | |
| download | emacs-cf237e277f6b033fd8d47ecdc466722c73de5d96.tar.gz emacs-cf237e277f6b033fd8d47ecdc466722c73de5d96.zip | |
* callproc.c (relocate_fd): Use F_DUPFD if defined.
Diffstat (limited to 'src/callproc.c')
| -rw-r--r-- | src/callproc.c | 14 |
1 files changed, 10 insertions, 4 deletions
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) | |||
| 1288 | return fd; | 1288 | return fd; |
| 1289 | else | 1289 | else |
| 1290 | { | 1290 | { |
| 1291 | int new = dup (fd); | 1291 | int new; |
| 1292 | #ifdef F_DUPFD | ||
| 1293 | new = fcntl (fd, F_DUPFD, minfd); | ||
| 1294 | #else | ||
| 1295 | new = dup (fd); | ||
| 1296 | if (new != -1) | ||
| 1297 | /* Note that we hold the original FD open while we recurse, | ||
| 1298 | to guarantee we'll get a new FD if we need it. */ | ||
| 1299 | new = relocate_fd (new, minfd); | ||
| 1300 | #endif | ||
| 1292 | if (new == -1) | 1301 | if (new == -1) |
| 1293 | { | 1302 | { |
| 1294 | const char *message1 = "Error while setting up child: "; | 1303 | const char *message1 = "Error while setting up child: "; |
| @@ -1299,9 +1308,6 @@ relocate_fd (int fd, int minfd) | |||
| 1299 | emacs_write (2, message2, strlen (message2)); | 1308 | emacs_write (2, message2, strlen (message2)); |
| 1300 | _exit (1); | 1309 | _exit (1); |
| 1301 | } | 1310 | } |
| 1302 | /* Note that we hold the original FD open while we recurse, | ||
| 1303 | to guarantee we'll get a new FD if we need it. */ | ||
| 1304 | new = relocate_fd (new, minfd); | ||
| 1305 | emacs_close (fd); | 1311 | emacs_close (fd); |
| 1306 | return new; | 1312 | return new; |
| 1307 | } | 1313 | } |