* [PATCH] selftests/proc: avoid exit() from SIGALRM handler
@ 2026-09-04 12:37 Paul Dolan
2026-09-08 16:40 ` Alexey Dobriyan
0 siblings, 1 reply; 2+ messages in thread
From: Paul Dolan @ 2026-09-04 12:37 UTC (permalink / raw)
To: Shuah Khan; +Cc: Alexey Dobriyan, linux-kselftest, linux-kernel, linux-fsdevel
proc-tid0 uses SIGALRM to stop the test after one second, but the
signal handler calls exit(), which is not async-signal-safe.
Set a sig_atomic_t flag from the handler instead and let the main loop
terminate normally. This also preserves the existing atexit cleanup
that kills the worker child.
Fixes: 0658a0961b0a ("procfs: do not list TID 0 in /proc/<pid>/task")
Signed-off-by: Paul Dolan <paul.dolan.dev@gmail.com>
---
tools/testing/selftests/proc/proc-tid0.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/proc/proc-tid0.c b/tools/testing/selftests/proc/proc-tid0.c
index 58c1d7c90a8e..79d3704b2b33 100644
--- a/tools/testing/selftests/proc/proc-tid0.c
+++ b/tools/testing/selftests/proc/proc-tid0.c
@@ -25,6 +25,8 @@
static pid_t pid = -1;
+static volatile sig_atomic_t alarmed;
+
static void atexit_hook(void)
{
if (pid > 0) {
@@ -39,7 +41,7 @@ static void *f(void *_)
static void sigalrm(int _)
{
- exit(0);
+ alarmed = 1;
}
int main(void)
@@ -62,7 +64,7 @@ int main(void)
signal(SIGALRM, sigalrm);
alarm(1);
- while (1) {
+ while (!alarmed) {
DIR *d = opendir(buf);
struct dirent *de;
while ((de = readdir(d))) {
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/proc: avoid exit() from SIGALRM handler
2026-09-04 12:37 [PATCH] selftests/proc: avoid exit() from SIGALRM handler Paul Dolan
@ 2026-09-08 16:40 ` Alexey Dobriyan
0 siblings, 0 replies; 2+ messages in thread
From: Alexey Dobriyan @ 2026-09-08 16:40 UTC (permalink / raw)
To: Paul Dolan; +Cc: Shuah Khan, linux-kselftest, linux-kernel, linux-fsdevel
On Fri, Sep 04, 2026 at 01:37:52PM +0100, Paul Dolan wrote:
> proc-tid0 uses SIGALRM to stop the test after one second, but the
> signal handler calls exit(), which is not async-signal-safe.
>
> Set a sig_atomic_t flag from the handler instead and let the main loop
> terminate normally. This also preserves the existing atexit cleanup
> that kills the worker child.
>
> Fixes: 0658a0961b0a ("procfs: do not list TID 0 in /proc/<pid>/task")
> Signed-off-by: Paul Dolan <paul.dolan.dev@gmail.com>
Yeah, yeah.
Reviewed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> static void sigalrm(int _)
> {
> - exit(0);
> + alarmed = 1;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-08 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 12:37 [PATCH] selftests/proc: avoid exit() from SIGALRM handler Paul Dolan
2026-09-08 16:40 ` Alexey Dobriyan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.