On 2026-02-10 23:06, 左洪盛 wrote:
From d52984cc2e356797789deb221a637f5cf5890107 Mon Sep 17 00:00:00 2001 From: Zuo <[email protected]> Date: Wed, 11 Feb 2026 14:16:38 +0800 Subject: [PATCH] sort: make sighandler async-signal-safe* src/sort.c (main,sighandler): Make sighandler async-signal-safe by removing non-async-signal-safe calls from signal handler. Use SA_RESETHAND flag and call unlink() directly.
I don't see why this patch is needed; on the contrary, it seems to introduce a bug.
Currently, the signal handler of 'sort' uses only the system calls 'unlink', 'signal', and 'raise', all of which are async-signal-safe. So the patch does not make 'sort' any more async-signal-safe than it already is.
There is no need to call '_exit', as 'raise' causes a signal to be delivered, which causes the program to exit.
Using SA_RESETHAND would introduce a race condition bug, as a signal could arrive during signal handling and this would kill the process, which means temporary files would not be cleaned up.
