[hackers] [scroll] fix race condition between sigwinch and sigchld || Jan Klemkow

From: <git_AT_suckless.org>
Date: Thu, 30 Apr 2020 22:14:39 +0200 (CEST)

commit 1dbf2dce08892df710645ddbd2ce12759ec95078
Author: Jan Klemkow <j.klemkow_AT_wemelug.de>
AuthorDate: Thu Apr 30 22:12:50 2020 +0200
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Thu Apr 30 22:12:50 2020 +0200

    fix race condition between sigwinch and sigchld
    
    sigwinch died if it tries to set the window size
    to a file descriptor of an exited child. Thus,
    we just ignore this error in that situation.

diff --git a/scroll.c b/scroll.c
index 9242936..28cd653 100644
--- a/scroll.c
+++ b/scroll.c
_AT_@ -96,8 +96,11 @@ sigwinch(int sig)
 
         if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1)
                 die("ioctl:");
- if (ioctl(mfd, TIOCSWINSZ, &ws) == -1)
+ if (ioctl(mfd, TIOCSWINSZ, &ws) == -1) {
+ if (errno == EBADF) /* child already exited */
+ return;
                 die("ioctl:");
+ }
         kill(-child, SIGWINCH);
         doredraw = true;
 }
Received on Thu Apr 30 2020 - 22:14:39 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 30 2020 - 22:24:33 CEST