From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796167596; b=llCVUrpwhsimIOMun/KWQy4sYdMCRHiXsE4WKzLXs/RCdTlLJgC5J9mzTYUbptp5H4zb pbESnNIPLkt0a4zN+1GT48Tizbc9al8NoEV9cnubxdz94yEMUwsqsZfkRzi2+xnBBvr9T 7R1nWCT2I7idFYZISNN6kdsrDBUmmV2dKuEA5xPclEIVMuOgqfA0aeRj0F4kq8VTzB7Dh 1WO6i4WezMnb1iqMAQNd9r3hHa1fMP0rKUSpKIQPeO8/VxAndYHReicqYf5tR5RWZqyPe Ilc4FlQlIxrHchOU86pvb1Uafnheb8/Cv6ioxrVf/pApN4rVMbSjzD5hQxg6CAt02OA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796167596; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=tYJEqGOPPLf45uxbumuTw+PaplRFrBLEghL8pGQHY8k=; b=YYyt9Cx7ZNGHlaE1NppIQHXjRzpuwQCEWwlK+fht1Sxa2VTtpSjNW1fAhT5laiHV+uHv 6co522vNk8g3IKnRpcz+IDAmx+vOScmfnm6QUPQ8qUbnhV46OFiBww9NV7CDquNx6irZs C1AfFOv3MEKgxsCOxfhagjp7oPI5mGRRihw9DqbUwaQISiP5WDv4x7ZM5Cn5NGfffw2Mx Jh8btd82cTn3a9JFZiVgWewseVZ5fVLogzTXvNbnznwAO8yIbojwytxRVFJhFhsfJhMyd D+zpUDobJPO2sW0Az9id/VD57Qno9oBZFs55uzKCyVlJg3Pk4whOXcIvFkoRvKCNb6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="OnN4A9n/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C03CB606A320; Tue, 1 Dec 2026 23:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OnN4A9n/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 466531F000C1; Tue, 1 Dec 2026 23:26:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796167596; bh=tYJEqGOPPLf45uxbumuTw+PaplRFrBLEghL8pGQHY8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=OnN4A9n/s7mD4gRK7dtbGUNlJGotw9k2vsI7igwlrEjRidWFjOAL3kMQ+1pKCrysR kOvPn7moW+5QfRS2OC32yb/pV6IE3qCWBPTORjqWK52v0Ch74A+XvgJZT8zZLyayoE ahQHsbfU5g1QuuXuiVsCeNXCyyrTpVbi1+wW8EBC6b+lwCA5Y0KLK79tGzBdnLhwFp l4AfH6LZVs11QcTn0t1hfqag0QH+fMtPU3hgVMC+pWVXFQuUlKNVPJDENoZ/vuY3BK oGwYK3SBXMpPyVKcijJrP6mAK/zlmw7y9cDRwlfwYtpoI+oxnMjs5Mw8zUFQVxkB78 eXmDwEPsRoBnw== Date: Wed, 2 Dec 2026 00:26:30 +0100 From: Alejandro Colomar To: Raphael Bauer Cc: linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , Tejun Heo , Matt Fleming , "Eric W. Biederman" , Arnd Bergmann , Thomas Gleixner , Peter Zijlstra Subject: Re: sigwaitinfo.2: sigtimedwait() fails with EINTR, without a signal handler, when another thread accepts a process-directed signal Message-ID: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sokndyeyzrko7nmy" Content-Disposition: inline In-Reply-To: --sokndyeyzrko7nmy Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable From: Alejandro Colomar To: Raphael Bauer Cc: linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , Tejun Heo , Matt Fleming , "Eric W. Biederman" , Arnd Bergmann , Thomas Gleixner , Peter Zijlstra Subject: Re: sigwaitinfo.2: sigtimedwait() fails with EINTR, without a signal handler, when another thread accepts a process-directed signal Message-ID: References: MIME-Version: 1.0 In-Reply-To: Hi Raphael, > Date: 2026-12-01 14:05:28+0100 > From: Raphael Bauer > > Hi Alejandro, >=20 > When two threads of a process wait in sigtimedwait() for the same signal = and > that signal is sent to the process (here by alarm()), one thread accepts = it, > and the other fails with EINTR at that same moment instead of failing with > EAGAIN at its timeout. No signal handler is installed. The EINTR entry in > sigwaitinfo.2 (the page for sigtimedwait(2)) names only a signal handler = as > the cause, and I found nothing else in that page or in signal(7) that cov= ers > this case. I read this in man-pages 6.13 as installed; the current page in > man-pages.git has the same wording. >=20 > I can't tell whether the page or the kernel should change, so I'm copying > LKML. I have CCd a few people that have been involved in implementing sigtimedwait(2) --according to git-blame(1)--. > Could you, or someone on LKML, say which it is? I don't know much about this API, so can't answer. But unless someone considers this a bug, I guess we should document what happens at the moment (it's good to CC them just in case). Would you mind preparing a patch for the manual page? >=20 > Reproducer: both threads block SIGALRM and wait for it with a timeout of = 2.5 > s; main calls alarm(1). >=20 > #define _GNU_SOURCE > #include > #include > #include > #include > #include > #include > #include >=20 > static pthread_barrier_t barrier; >=20 > static void *waiter(void *name) > { > sigset_t set; > struct timespec timeout =3D { 2, 500000000 }; /* 2.5 s */ > int sig; >=20 > sigemptyset(&set); > sigaddset(&set, SIGALRM); > pthread_barrier_wait(&barrier); > sig =3D sigtimedwait(&set, NULL, &timeout); > printf("%-6s: sigtimedwait() =3D %d%s%s\n", (char *) name, sig, > sig =3D=3D -1 ? ", errno " : "", sig =3D=3D -1 ? > strerrorname_np(errno) : ""); > return NULL; > } >=20 > int main(void) > { > sigset_t set; > pthread_t thread; >=20 > sigemptyset(&set); > sigaddset(&set, SIGALRM); > sigprocmask(SIG_BLOCK, &set, NULL); /* inherited by the thread > */ >=20 > pthread_barrier_init(&barrier, NULL, 2); > pthread_create(&thread, NULL, waiter, "thread"); > alarm(1); > waiter("main"); > pthread_join(thread, NULL); > return 0; > } >=20 > Output on SUSE Linux Enterprise Server 16.0 (kernel > 6.12.0-160000.5-default), the same in each of 10 runs; both lines appear > after 1.0 s, and 14 is SIGALRM: >=20 > main : sigtimedwait() =3D 14 > thread: sigtimedwait() =3D -1, errno EINTR Thanks! Please keep this reproducer in the commit message of the patch, if you send one. (Indent it so that git(1) doesn't consider the '#include' lines to be comments.) Have a lovely night! Alex >=20 > Without the alarm(1), both threads fail with EAGAIN after 2.5 s. I have n= ot > tried other kernels. >=20 > Thanks, > Raphael Bauer --=20 --sokndyeyzrko7nmy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmsPV6UACgkQ64mZXMKQ wqmD8Q/+Jbr73PbPKCI1E6Bk9KLNNYmU6i+NdhEehsqZ2C9Xcms6ncLhKFPqB2sc OQHqE0eMSYghr3f+J8W/d6s0IxEPR5CSo2zMJJS5zVN+HJNo+reH2YaHWVtwjDpG Fc6yRV1tBYGh7bdHAYOsUiWj3hlXceAQ/czDcsXiB9hHmJ/ctASWf76SZaImiNfS MM33xe3xz3vh3PQpn3AwT1k5eHSXUewS7Bo+0if6hxDT4gpntwzg4uAIAt8sjBB7 OJ5sIKzc01pq9Veegv8O2SVmZXwRatfA1GZmbOKJ4OUCYnlAuYvYEJNm0hb9DnMY PjpJJYMCAgoTixbUx5KaiZcU4nQKk2J0bw+8OqBEZ+rH33VDNcGpS0NbrZqsbvVb FMT8rH/ZNa5EyPqqg4/o+keL1PTbBar344QAn7tYF7394716cBFU+V7lCVho/f3b PcAyQCZp+CJprYeOMram75gb7S2a8dyzem3StRDpaHVHZ5rxdLe+UvfmQ1ULEKp8 rc2wbvoCW8JL2bgdfmltiZ/xXC4vK2Tn+iw/wpoLE69KbPlakg5SV74kCcyJjpr5 dWy83Q/2X8REuf5T8OjEny+qOL2KkyGa02s3X6iWrdC8gMY/JJJTcVrf8y0IPtKI z25TJ99D42lCOq534W0DngboIgjwn8CT/SH1qOjEBFHTf+wi4pk= =/lvh -----END PGP SIGNATURE----- --sokndyeyzrko7nmy--