GNU bug report logs - #56218
[PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Sat, 25 Jun 2022 17:19:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 56218 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 56218 <at> debbugs.gnu.org
Subject: Re: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of
 open-inferior #:error-port.
Date: Mon, 27 Jun 2022 12:37:58 +0100
[Message part 1 (text/plain, inline)]
Maxime Devos <maximedevos <at> telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Christopher Baines schreef op za 25-06-2022 om 18:18 [+0100]:
>>              (close-port parent)
>>              (close-fdes 0)
>>              (close-fdes 1)
>> +            (close-fdes 2)
>>              (dup2 (fileno child) 0)
>>              (dup2 (fileno child) 1)
>>              ;; Mimic 'open-pipe*'.
>> -            (unless (file-port? (current-error-port))
>> -              (close-fdes 2)
>> -              (dup2 (open-fdes "/dev/null" O_WRONLY) 2))
>> +            (dup2 (if (file-port? (current-error-port))
>> +                      (fileno (current-error-port))
>> +                      (open-fdes "/dev/null" O_WRONLY))
>> +                  2)
>
> I don't this would work if (current-error-port) has fd 1. Would
> move->fdes be appropriate here?  The following seems less fragile (*)
> to me (untested, also I didn't look at the context)
>
>   (move->fdes [child port] 0)
>   (move->fdes (dup [child port]) 1)
>   (if (file-port? (current-error-port))
>       (move->fdes (current-error-port) 2)
>       (move->fdes (open-file "/dev/null" O_WRONLY) 2))
>
>
> (*): move->fdes automatically moves ports out of the way.  Also, if one
> of the moves fails, then at least (current-output-port) etc will still
> have a correct fd so some error reporting should be possible

Maybe. I haven't actually tried this yet, but the docs seem to suggest
it would work.

Thanks,

Chris
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 2 years and 318 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.