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 EB6735A004F for ; Wed, 07 Aug 2024 09:23:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723015400; 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=0+ZewaNvnJIqJNwGT4f63MfLRYs8IWE+ybMfCUC/AHQ=; b=Yb+mi/roFic047I4le3dlIysHrniHOxoeZX4hzKH1e9ifs2Sa6HOfTZk15S7Onv2IIL+CN qfF8+bGUdQQPqVKJpbHg6IuLzhH3MwSN+wJsmgaMoEt3PpGBiS628F/e5owpWyTUVrVEBA YjJvmYP/aLjSAhHjc9lAZ3y5gekRz4I= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-CoB7d_veM1qeQ1oTDZno6g-1; Wed, 07 Aug 2024 03:23:18 -0400 X-MC-Unique: CoB7d_veM1qeQ1oTDZno6g-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42817980766so10207945e9.3 for ; Wed, 07 Aug 2024 00:23:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723015398; x=1723620198; 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=0+ZewaNvnJIqJNwGT4f63MfLRYs8IWE+ybMfCUC/AHQ=; b=GH9UIyXpVJuS92ohVgtXypQNigfjJ9S89chcZrQDA4UqxwjGvi3grPqgPjirRWrpsf NIpV2DpcLENW8eK+UMgACuNqMXuQRfIJnxE3vlCDooAX5hIr2sUEk1d3OAv2iyv3KzF0 RtyiINlM/21tdgBTBLJ/+pL5dIli7rplIvKfVfcVI+uRzfa1Njp3/n4VMNTfhddzPfg7 GyU2lNf7W3gH5uwc5Q78RLCoBNoBidz+I8LFyXhNHh3NZ/LA5jxq+n1A2x/0QevblZqy 4lfsW61xfP1+zPYqBXEkD02q7qBPzDxkz+yPgrfInF/0GoRP0wnktVvBsdQ0OV5DAdTF l9fg== X-Gm-Message-State: AOJu0Yzk7ks90CNlW9aZ6PcGR97Lvax1d/QJ+JhhCS5eAOvL1PhP5NGy c/1BJYzq+0FyrfB9eSTp6P4+y2xF0T/4INEdcYFzL4S15TEvXfOpBXRNgSGq+dYWdRrcsM5kvUV WM/khSsfN13dMM+R0SYHkZoKTCD8zk7Rc23adUNuC1YDlKqafZg== X-Received: by 2002:a05:600c:4f53:b0:426:5416:67d7 with SMTP id 5b1f17b1804b1-428e6b7f149mr116000085e9.27.1723015397624; Wed, 07 Aug 2024 00:23:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+lo7Pe+3whOm1v4nvj6nbWI1EMFhufuH67wH9rVjWcPgjK5fvnObUVCYy6oDlX3debpT+2A== X-Received: by 2002:a05:600c:4f53:b0:426:5416:67d7 with SMTP id 5b1f17b1804b1-428e6b7f149mr115999875e9.27.1723015397024; Wed, 07 Aug 2024 00:23:17 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290579fed7sm15358415e9.17.2024.08.07.00.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 00:23:16 -0700 (PDT) Date: Wed, 7 Aug 2024 09:23:14 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 02/22] nstool: Propagate SIGTERM to processes executed in the namespace Message-ID: <20240807092314.13642dda@elisabeth> In-Reply-To: <20240805123701.1720730-3-david@gibson.dropbear.id.au> References: <20240805123701.1720730-1-david@gibson.dropbear.id.au> <20240805123701.1720730-3-david@gibson.dropbear.id.au> 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=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: B74IT4ELUCA32YZHKY4BXQOBZD2BGJUO X-Message-ID-Hash: B74IT4ELUCA32YZHKY4BXQOBZD2BGJUO 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, Cleber Rosa 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 Mon, 5 Aug 2024 22:36:41 +1000 David Gibson wrote: > Particularly in shell it's sometimes natural to save the pid from a process > run and later kill it. If doing this with nstool exec, however, it will > kill nstool itself, not the program it is running, which isn't usually what > you want or expect. > > Address this by having nstool propagate SIGTERM to its child process. It > may make sense to propagate some other signals, but some introduce extra > complications, so we'll worry about them when and if it seems useful. > > Signed-off-by: David Gibson > --- > test/nstool.c | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) > > diff --git a/test/nstool.c b/test/nstool.c > index a6aca981..fc357d8a 100644 > --- a/test/nstool.c > +++ b/test/nstool.c > @@ -345,17 +345,39 @@ static int openns(const char *fmt, ...) > return fd; > } > > +static pid_t sig_pid; > +static void sig_handler(int signum) > +{ > + int err; > + > + err = kill(sig_pid, signum); > + if (err) > + die("Propagating %s: %s\n", strsignal(signum), strerror(errno)); As I've just been bitten by this, f30ed68c5273 ("pasta: Save errno on signal handler entry, restore on return when needed"), I was kind of wondering if we should save and restore errno, regardless of the fact it's not needed here (if kill() affects ernno, we won't return). On the other hand this handler at the moment is simple enough that we would notice if it's needed because of some further changes. -- Stefano