Re: [hackers] [dwm][PATCH] do not call signal-unsafe function inside sighanlder
On Tue, Jul 19, 2022 at 12:05:48AM +0200, François-Xavier Carton wrote:
> Technically, no standard guarantees that the handler stays after being
> called once. The implementation could reset it to the default action.
Hmm, didn't know about that.
> One may want to re-add a call to signal here, without error checking, to
> ensure the handler remains in case SIGCHLD is raised multiple times.
Alternatively we could revert this patch and then change the `die` call
to `write` and `_exit`; both of which are async-signal-safe.
void
sigchld(int unused)
{
if (signal(SIGCHLD, sigchld) == SIG_ERR) {
char errmsg[] = "Can't install SIGCHLD handler";
write(2, errmsg, sizeof errmsg);
_exit(1);
}
while (0 < waitpid(-1, NULL, WNOHANG));
}
This can't call `perror` similar to `die` as that's not signal safe.
- NRK
Received on Tue Jul 19 2022 - 02:42:34 CEST
This archive was generated by hypermail 2.3.0
: Tue Jul 19 2022 - 02:48:29 CEST