From: Richard M. Stallman Date: Thu, 29 Jun 1995 17:30:50 +0000 (+0000) Subject: (child_setup): Don't get confused if in == err. X-Git-Tag: emacs-19.34~3429 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f29f9e4afc2a54e937e0403555a41734599725be;p=emacs.git (child_setup): Don't get confused if in == err. --- 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);