unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* help needed with stderr redirection
@ 2022-10-21 23:29 Csepp
  2022-10-22  6:26 ` tomas
  2022-10-22  8:23 ` Josselin Poiret
  0 siblings, 2 replies; 3+ messages in thread
From: Csepp @ 2022-10-21 23:29 UTC (permalink / raw)
  To: guile-devel

I have this short snippet of code for a Guix related utility script and
for the love of the Glowcloud it does not want to work.  I want to
filter stderr for certain lines and they are not being redirected.  When
running the full script from a shell, it correctly captures standard
out, but all the warnings and errors from the subprocess and/or its
children go directly to the terminal.

I looked in the Guix sources to see how others do it and found mention
of a possibly related bug:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52835
Is that still relevant?  Because debuggs is just, khm, great, I don't
see any clear indication of what its status is.

(define (with-input-from-make thunk)
  (with-error-to-port
      (current-output-port)
    (lambda _
      (with-input-from-port
          (open-pipe* OPEN_READ "make")
        thunk))))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help needed with stderr redirection
  2022-10-21 23:29 help needed with stderr redirection Csepp
@ 2022-10-22  6:26 ` tomas
  2022-10-22  8:23 ` Josselin Poiret
  1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2022-10-22  6:26 UTC (permalink / raw)
  To: guile-devel

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

On Sat, Oct 22, 2022 at 01:29:05AM +0200, Csepp wrote:
> I have this short snippet of code for a Guix related utility script and
> for the love of the Glowcloud it does not want to work.  I want to
> filter stderr for certain lines and they are not being redirected.  When
> running the full script from a shell, it correctly captures standard
> out, but all the warnings and errors from the subprocess and/or its
> children go directly to the terminal.
> 
> I looked in the Guix sources to see how others do it and found mention
> of a possibly related bug:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52835
> Is that still relevant?  Because debuggs is just, khm, great, I don't
> see any clear indication of what its status is.
> 
> (define (with-input-from-make thunk)
>   (with-error-to-port
>       (current-output-port)
>     (lambda _
>       (with-input-from-port
>           (open-pipe* OPEN_READ "make")
>         thunk))))

I think `with-error-to-port' just directs the error messages of the
current process. Not the ones of the subprocess you are invoking with
open-pipe*. Could that be the case?

To get a better idea of what's going on, you can let a subshell handle
that redirection for you, substitute `open-pipe*' with the star-less
variable and try:

  (open-pipe OPEN_READ "make 2>&1")

If that works as you expect, you can work your way from there. If not,
we've learnt something :)

Cheers
-- 
t

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: help needed with stderr redirection
  2022-10-21 23:29 help needed with stderr redirection Csepp
  2022-10-22  6:26 ` tomas
@ 2022-10-22  8:23 ` Josselin Poiret
  1 sibling, 0 replies; 3+ messages in thread
From: Josselin Poiret @ 2022-10-22  8:23 UTC (permalink / raw)
  To: Csepp, guile-devel

Hi,

Csepp <raingloom@riseup.net> writes:

> I looked in the Guix sources to see how others do it and found mention
> of a possibly related bug:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52835
> Is that still relevant?  Because debuggs is just, khm, great, I don't
> see any clear indication of what its status is.

From what I understand this bug is still relevant.  This would affect
you here if your current-error-port has a fd <= 2 when using open-pipe.
However, here you're redirecting the error port to the output port's
value before opening the pipe, so the result is expected!  You can have
a look at gnu/installer/utils.scm in Guix to see how we're doing it
right now, beware, it's hackish (we don't actually use the pipe to
redirect at all, instead relying on the newly spawned process reusing
the current-input/output/error-port).

The patch I posted last in the debbugs report above should add a new
primitive that would let us redirect all of stdin/out/err independently.

Best,
-- 
Josselin Poiret



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-22  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 23:29 help needed with stderr redirection Csepp
2022-10-22  6:26 ` tomas
2022-10-22  8:23 ` Josselin Poiret

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).