[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #
From: |
Christopher Baines |
Subject: |
[bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port. |
Date: |
Mon, 27 Jun 2022 12:37:58 +0100 |
User-agent: |
mu4e 1.6.10; emacs 28.1 |
Maxime Devos <maximedevos@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
Description: PGP signature