Skip to content

Commit

Permalink
do not call signal-unsafe function inside sighanlder
Browse files Browse the repository at this point in the history
die() calls vprintf, fputc and exit; none of these are
async-signal-safe, see `man 7 signal-safety`.
  • Loading branch information
N-R-K authored and dther committed Dec 11, 2023
1 parent f121575 commit f962517
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,8 @@ setup(void)
Atom utf8string;

/* clean up any zombies immediately */
if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("can't install SIGCHLD handler:");
sigchld(0);

/* init screen */
Expand Down Expand Up @@ -1631,8 +1633,6 @@ showhide(Client *c)
void
sigchld(int unused)
{
if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("can't install SIGCHLD handler:");
while (0 < waitpid(-1, NULL, WNOHANG));
}

Expand Down

0 comments on commit f962517

Please sign in to comment.