diff options
author | Richard M. Stallman <rms@gnu.org> | 1995-06-29 17:30:50 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1995-06-29 17:30:50 +0000 |
commit | 6b5ef859aebd7d70754ed75bdefc8d24c2a634cb (patch) | |
tree | 6b94ca30256f5adc0611ad4969975e0700e5f3a9 /src/callproc.c | |
parent | 5b7a21e1cb9b2c8ed30c98d928d8797f9f9c9631 (diff) | |
download | emacs-6b5ef859aebd7d70754ed75bdefc8d24c2a634cb.tar.gz |
(child_setup): Don't get confused if in == err.
Diffstat (limited to 'src/callproc.c')
-rw-r--r-- | src/callproc.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/callproc.c b/src/callproc.c index f87223c8d44..ea995b6b09f 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -807,14 +807,25 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) descriptors zero, one, or two; this could happen if Emacs is started with its standard in, out, or error closed, as might happen under X. */ - in = relocate_fd (in, 3); - if (out == err) - err = out = relocate_fd (out, 3); - else - { + { + int oin = in, oout = out; + + /* We have to avoid relocating the same descriptor twice! */ + + in = relocate_fd (in, 3); + + if (out == oin) + out = in; + else out = relocate_fd (out, 3); + + if (err == oin) + err = in; + else if (err == oout) + err = out; + else err = relocate_fd (err, 3); - } + } close (0); close (1); |