From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=T9NrofTU; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id EE3F85A0280 for ; Wed, 28 May 2025 09:45:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748418338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cOId0wqi/o6ZgiYBkbTYUMcVAShqXanWUaMPcw0m2lA=; b=T9NrofTUqZA/1ghDfRplC0SnkdghbhIHseNIuUDkpjazI1uyDTtHZLXJGwA8wfp72Om8VB rG1MydiohJ5l3TkASadVxwqDKEX8J36pumQpXllzUMxxcInp6BuIbQcFz9LsLQt0whR8cm QgkUEDlgV3I7/JlLgW9prYYGgKUPJMc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-AzkJMM5bNEO8FFm8WE7Tfw-1; Wed, 28 May 2025 03:45:37 -0400 X-MC-Unique: AzkJMM5bNEO8FFm8WE7Tfw-1 X-Mimecast-MFC-AGG-ID: AzkJMM5bNEO8FFm8WE7Tfw_1748418336 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-450cb8f8b1bso315945e9.3 for ; Wed, 28 May 2025 00:45:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748418336; x=1749023136; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cOId0wqi/o6ZgiYBkbTYUMcVAShqXanWUaMPcw0m2lA=; b=TOx5ezMPBaoPjlJEfbs1FcTeh4jE4F9W64FJjecumQnr4lGOwi4DMD8PFJ0VKciTve TpF7+BMAeIxrf3YvjOIcxn8uAOggYS2POoPS+3jD+StHb1/RkR28S9PlFURrMGAbJMwC PT0Lmet5mM9DgK+cvpl8HFcEkHJKvAWpxRGxcnvN7yfyTihrsCrDsuYpeSomlQz/hu9g RDO3c3IZABIVUmExMqvrhQ1G2nq24xGq36FOed+xZYqPzP/nrwM1CsZr+V1dqWmA4L2K MKXWgYvIyiVpz0cdJkBiIKGxE6FoaBAW210XwvksThzZUBEbekoopsahH+RAWVLwOVMX MHTg== X-Forwarded-Encrypted: i=1; AJvYcCXO4FlnywT1s9FS9HrMWyMiT5SP9YfO7GE2d2kHk2qeL7UZ6PArHRGePSxsAeK05pRa7cCJZ1Gy4WEA@passt.top X-Gm-Message-State: AOJu0YwgEjN3fiHQsQOzk6EnoV+FM0egufmia4efaJcMJwtSJC+d/eg4 26IvA1dRcyaw8AHvSSd3ct1vkEdhSBCuZvKgMtD78oPrVQyZpCwf0ko0euu4DDBSAuvSVKntqlQ iNxviJ10XQ/oCyD3CNa+x4r8Der7+Yrj+tIC+P0tCR2+v9n97GQ8p1KA= X-Gm-Gg: ASbGncv5w7zxy7NaltnEpUSD4DGa+BEilEFaHIl0MpuRUVOt78th7E4+0ZO0nCDGAt3 Jjs058ZSVYB6FnBPyHGAfcJigyquethxKuYAOuIRWmOYfQ6Ed6kHKUu/WomeJRfc7Pc7MIEK5bA yP2sF+7yZUEJMXlf9HI7yEq6l7n3vwappm6QauXvFtsTym5lk+U0n3ewkOrmZtc2yH7DRc3V2Tg EI0HVWFXrzYN7b2igZs0f0CgQ6M/gUPsPJNKaFOcy+yyFrw9WkP+lv5BFgqLyNWbY4U+sN7HPUr GnuD29clWRSOOIjmbeLTM53fSph/AEVIGimQnQ3+ X-Received: by 2002:a05:600c:1e25:b0:43d:db5:7af8 with SMTP id 5b1f17b1804b1-44c92a547bbmr136516705e9.21.1748418336303; Wed, 28 May 2025 00:45:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6tLHqRh64znaShO0lIsf02b863/xs2DiR+CeT72cfQXZXnc9dcjNlcOuQAdp4TKiLpfHvHg== X-Received: by 2002:a05:600c:1e25:b0:43d:db5:7af8 with SMTP id 5b1f17b1804b1-44c92a547bbmr136516495e9.21.1748418335888; Wed, 28 May 2025 00:45:35 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4507255a13csm8852235e9.23.2025.05.28.00.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 May 2025 00:45:35 -0700 (PDT) Date: Wed, 28 May 2025 09:45:33 +0200 From: Stefano Brivio To: David Gibson Subject: Re: Can't pipe output of pasta --version Message-ID: <20250528094533.1bd932e8@elisabeth> In-Reply-To: References: <1378983862.3469095.1748366479602.ref@mail.yahoo.com> <1378983862.3469095.1748366479602@mail.yahoo.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vhpNiSHFs03RdRptW_g6saIUYZXQHJ5LLYUdgmviojU_1748418336 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: UHUIPZKRYKTYGY2IOE7HBH7UHJNGIOH4 X-Message-ID-Hash: UHUIPZKRYKTYGY2IOE7HBH7UHJNGIOH4 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "John Radley (jradxl2)" , "passt-user@passt.top" , Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: "For passt users: support, questions and answers" Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: [Cc: Paul as author of d0006fa78] On Wed, 28 May 2025 12:25:10 +1000 David Gibson wrote: > 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 > > 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. Well, that's something we looked into (of course...), and (I?) concluded that we never needed to flush stdio, which is the only otherwise useful thing glibc handlers would do for us, and which kind of holds... except for this case. And maybe for --help or any "early" exit. So we could fflush() as well in those cases, and just in those cases, with the added benefit that we don't need to add additional system calls to the permitted seccomp set, because if we exit early, we didn't install the seccomp filter yet. > 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. I'm on holiday too, I'll fix this later this week or next week, unless Paul is particularly inspired (or John wants to look into the issue a bit further and contribute a patch...?). -- Stefano