Explorar o código

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.
Jan Klemkow %!s(int64=5) %!d(string=hai) anos
pai
achega
1dbf2dce08
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      scroll.c

+ 4 - 1
scroll.c

@@ -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;
 }