public inbox for passt-user@passt.top
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "John Radley (jradxl2)" <jradxl2@gmail.com>
Cc: "passt-user@passt.top" <passt-user@passt.top>
Subject: Re: Can't pipe output of pasta --version
Date: Wed, 28 May 2025 12:25:10 +1000	[thread overview]
Message-ID: <aDZ0BtUnwA71MOzo@zatzit> (raw)
In-Reply-To: <1378983862.3469095.1748366479602@mail.yahoo.com>

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

On Tue, May 27, 2025 at 05:21:19PM +0000, John Radley (jradxl2) wrote:
> Hello,I can't pipe output like this:-
> $ pasta --version | grep pasta<blank!>
> but this works:-
> $ sudo apt install expect
> $ unbuffer pasta --version | grep pasta
> pasta 2025_05_12.8ec1341-9-g3262c9b
> 
> If this is the intended action, please can you tell me why?

Ouch.  No, that's not intended.

I initially assumed this was because we were sending the version
information to stderr instead of stdout, but that's not the case.

This is a bug introduced by d0006fa78 ("treewide: use _exit() over
exit()").  For --version we're displaying the information with
fprintf(), then immediately exiting with _exit().  When writing to a
pipe, stdout is buffered.  Normally the buffer would be flushed before
exiting, but using _exit() bypasses that.

We could fix this specific problem by adding an fflush(stdout) before
the _exit().  However, I worry that there might be other bugs we have
because we're not running libc installed exit handlers here and
elsewhere.  I was already a bit dubious about using _exit() by
default, and now I really don't think it was a good idea.

That said, I don't immediately have a better idea of how to address
the problem d0006fa78 was aiming to fix in the first place.

Well... I'm on holiday at the moment, so I won't be fixing it.
Laurent & Stefano, I hope the analysis above is helpful.

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

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

       reply	other threads:[~2025-05-28  2:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1378983862.3469095.1748366479602.ref@mail.yahoo.com>
     [not found] ` <1378983862.3469095.1748366479602@mail.yahoo.com>
2025-05-28  2:25   ` David Gibson [this message]
2025-05-28  7:45     ` Can't pipe output of pasta --version Stefano Brivio
     [not found]     ` <174841834113.3062894.7293539982980796043@maja>
2025-05-28 23:31       ` Jon Maloy
2025-05-30  8:10         ` Stefano Brivio

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

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

  git send-email \
    --in-reply-to=aDZ0BtUnwA71MOzo@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=jradxl2@gmail.com \
    --cc=passt-user@passt.top \
    /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.
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 IMAP folder(s).