unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 56218@debbugs.gnu.org
Subject: [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port.
Date: Mon, 27 Jun 2022 12:37:58 +0100	[thread overview]
Message-ID: <87k092l4hn.fsf@cbaines.net> (raw)
In-Reply-To: <e10b2fcd29cf540e80453a19eb8973f636153d91.camel@telenet.be>

[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

  parent reply	other threads:[~2022-06-27 11:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-25 17:18 [bug#56218] [PATCH] guix: inferior: Fix the behaviour of open-inferior #:error-port Christopher Baines
2022-06-25 17:50 ` Maxime Devos
2022-06-25 20:59   ` Maxime Devos
2022-06-27 11:37   ` Christopher Baines [this message]
2022-06-26 15:46 ` Ludovic Courtès
2022-06-27 11:39   ` Christopher Baines
2022-07-05 15:12     ` Ludovic Courtès
2022-07-08 12:54       ` bug#56218: " Christopher Baines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k092l4hn.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=56218@debbugs.gnu.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).