From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 513565A004F for ; Tue, 18 Jun 2024 08:01:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718690468; 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=oy1FZIaltmj8po2Ufjl8NuEvav/ywOLMWsuurHIx/dg=; b=CgQP7ZFBiTPxwDdu/g5MNYO8t3R8J03NmqDySZTnsGLT7qw4qR4hnF/kxnHcDdJozjrJg1 kd4cy8Nrhuft89caw29g7ZiLdiabJWpOBVPaX+MmgcgYx8m/rZWqUPGFAEOM9EUjZUa3eT dTwQS/CNFocLIipid62hMi9gMc+QacY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-y3liYqU7Og-wFfIQWc-nkA-1; Tue, 18 Jun 2024 02:01:06 -0400 X-MC-Unique: y3liYqU7Og-wFfIQWc-nkA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-795cce8b773so733514885a.3 for ; Mon, 17 Jun 2024 23:01:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718690466; x=1719295266; 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=v82WSAi/cRSYFFLnI3rdKwl8QbeB3Cj31OOgAQYBuZo=; b=s3uK1xErFKbEaZHdW18urGdFXRsl7QxW7Qsm3HrtOjOVFjMh47E/eT6dUfOnI/qGZ9 wLMoSl1Ke4qGOb2j025qyr45WTlzjFiTLWXF2pNn/VmYICNL3dRuc7Ew+INT3RVvD0bj vwUPB75qItia6NPyuT/cDooHZ2c61z5rB7nMTJ9wQqI3Fw05FaDgETXBBAykKf218u7k KFHSl5O5lMhBtPwi+AC25GMpK72yXqGxokevv19PDUbIGGcokBBJHGq+yyC8UlBB0Lxb kdsBZ9Sxg8TdezD/wry6S4xx1uDAcnya2X679QntKnx3lcnlIfCcmjR8lB/R9+VWuq0Z 41cQ== X-Gm-Message-State: AOJu0YwbWcXZ0xOkGy+0kkMpaamcyHW17aF5ho1A9rWrszUbeflEwQfb LSwfzFI7peLWcrlE+pAhVmRe2ooVIQIXGYHKM73tAQgVtm7HRRj+Ac/K8g++4x0JYxxShP9Wcka cC/jXC/EFVzLUHYF3J7d8Np+4rvRg/XJx/nVuxF3ScFCkTf7Y6A== X-Received: by 2002:a05:620a:2481:b0:795:5af6:2d8a with SMTP id af79cd13be357-798d24218e6mr1319655385a.23.1718690465551; Mon, 17 Jun 2024 23:01:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDu6YCpr8S2D2cy/q2+RRZyC20eQZCSsX9Y43apHH0TftZy0TZs/CKM9B8XDsxIbSKPq9JCg== X-Received: by 2002:a05:620a:2481:b0:795:5af6:2d8a with SMTP id af79cd13be357-798d24218e6mr1319652185a.23.1718690464918; Mon, 17 Jun 2024 23:01:04 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798abc02e72sm494030285a.96.2024.06.17.23.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2024 23:01:03 -0700 (PDT) Date: Tue, 18 Jun 2024 08:00:14 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 1/6] conf, passt: Don't try to log to stderr after we close it Message-ID: <20240618080004.5fb4e355@elisabeth> In-Reply-To: References: <20240617120319.1206857-1-sbrivio@redhat.com> <20240617120319.1206857-2-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 67ADEEZNNXYE4IK7LNRAVO2FKDVG3S6C X-Message-ID-Hash: 67ADEEZNNXYE4IK7LNRAVO2FKDVG3S6C 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-dev@passt.top, Yalan Zhang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 18 Jun 2024 10:36:28 +1000 David Gibson wrote: > On Mon, Jun 17, 2024 at 02:03:14PM +0200, Stefano Brivio wrote: > > If we don't run in foreground, we close standard error as we > > daemonise, so it makes no sense to check if the controlling terminal > > is an interactive terminal or if --force-stderr was given, to decide > > if we want to log to standard error. > >=20 > > Make --force-stderr depend on --foreground. > >=20 > > Signed-off-by: Stefano Brivio =20 >=20 > Reviewed-by: David Gibson >=20 > > --- > > conf.c | 3 +++ > > passt.c | 2 +- > > 2 files changed, 4 insertions(+), 1 deletion(-) > >=20 > > diff --git a/conf.c b/conf.c > > index 94b3ed6..dbdbb62 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -1693,6 +1693,9 @@ void conf(struct ctx *c, int argc, char **argv) > > =20 > > =09conf_ugid(runas, &uid, &gid); > > =20 > > +=09if (!c->foreground && c->force_stderr) > > +=09=09die("Can't log to standard error if not running in foreground"); > > + > > =09if (logfile) { > > =09=09logfile_init(c->mode =3D=3D MODE_PASTA ? "pasta" : "passt", > > =09=09=09 logfile, logsize); > > diff --git a/passt.c b/passt.c > > index a5e2c5a..aa9648a 100644 > > --- a/passt.c > > +++ b/passt.c > > @@ -302,7 +302,7 @@ int main(int argc, char **argv) > > =09if (isolate_prefork(&c)) > > =09=09die("Failed to sandbox process, exiting"); > > =20 > > -=09if (!c.force_stderr && !isatty(fileno(stderr))) > > +=09if (!c.foreground || (!c.force_stderr && !isatty(fileno(stderr)))) = =20 >=20 > What's the rationale for the isatty() check in any case? To implement the behaviour from the man page: -e, --stderr Log to standard error too. Default is to log to the sys=E2= =80=90 tem logger only, if started from an interactive terminal, and to both system logger and standard error otherwise. which was needed, in turn, because of earlier versions of passt and of the KubeVirt integration where passt was running in foreground, but (of course) not attached to a terminal, and there was no option to force printing to standard error. Given that KubeVirt doesn't have a system logger, it was otherwise impossible to get messages out of passt. It's an abomination that just adds complexity now, and I don't think anybody uses it that way anymore. I guess we should drop that, together with qrap, in a few months from now. --=20 Stefano