From f29f9e4afc2a54e937e0403555a41734599725be Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 29 Jun 1995 17:30:50 +0000 Subject: [PATCH] (child_setup): Don't get confused if in == err. --- src/callproc.c | 23 +++++++++++++++++------ 1 file 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); -- 2.39.2