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=fjmEN5dl; 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 359555A0280 for ; Fri, 30 May 2025 10:10:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748592622; 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=N7etpp3ryTJOW2E+0d+qJ9SyZ9jo6l7Pnx56TF+vS1M=; b=fjmEN5dl+7SUs1Cr9Rpbs37+aaOusMpiz9Wc6qklalZ3++ASCcQ8ct//svQRdX6H9XnkxH uxqs5RknsDQygraCFPs+8rTXxycLvTiR0fgCnjRgheUFkqNiaoIk5t3Fr7D2VuFsQ/ApUc LPUnMbXbzuOLsfXDD/OHAFLWCbcq/SM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-kSaqR2cuM6Csa08QJV3znA-1; Fri, 30 May 2025 04:10:20 -0400 X-MC-Unique: kSaqR2cuM6Csa08QJV3znA-1 X-Mimecast-MFC-AGG-ID: kSaqR2cuM6Csa08QJV3znA_1748592619 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-450dada0f83so1258015e9.0 for ; Fri, 30 May 2025 01:10:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748592619; x=1749197419; 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=N7etpp3ryTJOW2E+0d+qJ9SyZ9jo6l7Pnx56TF+vS1M=; b=ky8lIq8kFj29tWDMEOHeiZ0XskO7TLSwEtD/NGSaZ4hBylMb0Ab1Rv40ToIKYgirG7 39/eJyC01mwaELjt7qemMi04rBRTtSA5M+ovPXZ/D4Xrm+3E5ClJIliKPaxqDITTfsjW +NfPgTBS9jhcCC6c04PNyTbvdJkHmalXw6AvaN7EH9Gm4SCxaCLuICGVBqf4qyy7+Cwq Faz+RdH/SbTRG+djoTeE7NSdahV2HCv3gPejWhBHDxUgmYiorFUWQR6RNJw7ccleNCdR tE//dqcdzkOfSUYlohjlki9LyAJbtF6n2M9+SkmGbKMalDK5p1cunPm9TBGXdcIzgEMg pmqw== X-Gm-Message-State: AOJu0YwfItIxzLHPivLFS5LoY28mE53KxK6gecgVFNjq9iim/NR9Lv/N nIo2S7oVhrJl8idam1XsEt4vpRyZXBVXZnVmbF+Gi+dcac7WlSOCSG/GbCFuCi/JBSyqwcV8uvN Z5EPqKsNRSNiuwGTFhILmEOvBUEKX8Lf7EDQ9N5n91ckz30IUNczxlK4= X-Gm-Gg: ASbGncuVnaQh593H8N72jUgTTgLZDzHyYyU+mvTePd224Xec9TR6FXwAd1eoj1EpBUL Lx0OTxXtY34p5uGjV2qzPyEJahZJt1W5S6lSlHj6mbvBSfd+NcaSaQ53O8xxS4IhbIX2Vtokaes dSWW1yh6UVzLK4n/VnvAtZ8fR6tzW4hObUqV3eUknn6hE2+Kpm7wGkpGotAcGT0zQLT2dEgpsom l2EbdcGG/5zSW/dH9KsEIKHAIDRF08NrxrIACPDK75xWP6GK33gaLSkTsqvkM+y0uujp9oOomvr UKBZJaOm+NzHhfeppQ6up9k= X-Received: by 2002:a05:600c:81c8:b0:43c:fdbe:4398 with SMTP id 5b1f17b1804b1-450d651b642mr21944475e9.6.1748592618923; Fri, 30 May 2025 01:10:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQJgleF/7RQb29nTqxV4Y2Y9czn0HmqqExWlUdlkny05hoMiWKcMuEbcrYm84TDKbsynrK8Q== X-Received: by 2002:a05:600c:81c8:b0:43c:fdbe:4398 with SMTP id 5b1f17b1804b1-450d651b642mr21944185e9.6.1748592618509; Fri, 30 May 2025 01:10:18 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-450d8000d5dsm10958565e9.26.2025.05.30.01.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 May 2025 01:10:18 -0700 (PDT) Date: Fri, 30 May 2025 10:10:16 +0200 From: Stefano Brivio To: Jon Maloy Subject: Re: Can't pipe output of pasta --version Message-ID: <20250530101016.4f56d5d7@elisabeth> In-Reply-To: <7fbb6024-1584-45e1-b443-b646c85051a9@redhat.com> References: <1378983862.3469095.1748366479602.ref@mail.yahoo.com> <1378983862.3469095.1748366479602@mail.yahoo.com> <174841834113.3062894.7293539982980796043@maja> <7fbb6024-1584-45e1-b443-b646c85051a9@redhat.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: aOhPOhvg3sv4PgAtodRChiCatesjfwtZh0Tvj7gJk30_1748592619 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: WLWEEOKM4IQHEKVROVFH3CN4VYX3USOJ X-Message-ID-Hash: WLWEEOKM4IQHEKVROVFH3CN4VYX3USOJ 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: passt-user@passt.top, "John Radley (jradxl2)" , 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: On Wed, 28 May 2025 19:31:42 -0400 Jon Maloy wrote: > On 2025-05-28 03:45, Stefano Brivio via user wrote: > > [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...?). > > I'll take a look tomorrow. Patch with review thread now at: https://archives.passt.top/passt-dev/20250529170858.185281-1-jmaloy@redhat.com/ -- Stefano