Re: `script` dies on SIGWINCH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 05, 2007 at 04:06:51AM -0400, Mike Frysinger wrote:
> looks like the fix for the race condition may have included some unintended 
> side effects ... if you execute say:
> xterm -e script
> and then resize the xterm, script will terminate because the read() in 
> doinput() returned -1 (with errno being set to EINTR) ... i tried just making 
> the logic (read() > 0 || errno == EINTR), but that didnt seem to work very 
> well ;)

 Thanks! Fixed.

    Karel


commit 2b8bbb5fb0f024ea3917fedbbbaf0fab1c1f6555
Author: Karel Zak <kzak@xxxxxxxxxx>
Date:   Fri Oct 5 12:22:13 2007 +0200

    script: dies on SIGWINCH
    
    The "doinput" process doesn't make a difference between SIGWINCH and
    SIGCHILD.  This process also sends unnecessary SIGWINCH to child (the
    signal is ignored by child). Fixed.
    
    Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>

diff --git a/misc-utils/script.c b/misc-utils/script.c
index d3272df..3b957d8 100644
--- a/misc-utils/script.c
+++ b/misc-utils/script.c
@@ -99,6 +99,7 @@ int	tflg = 0;
 static char *progname;
 
 int die;
+int resized;
 
 static void
 die_if_link(char *fn) {
@@ -235,8 +236,14 @@ doinput() {
 	if (die == 0 && child && kill(child, 0) == -1 && errno == ESRCH)
 		die = 1;
 
-	while (die == 0 && (cc = read(0, ibuf, BUFSIZ)) > 0)
-		(void) write(master, ibuf, cc);
+	while (die == 0) {
+		if ((cc = read(0, ibuf, BUFSIZ)) > 0)
+			(void) write(master, ibuf, cc);
+		else if (cc == -1 && errno == EINTR && resized)
+			resized = 0;
+		else
+			break;
+	}
 
 	done();
 }
@@ -255,11 +262,10 @@ finish(int dummy) {
 
 void
 resize(int dummy) {
+	resized = 1;
 	/* transmit window change information to the child */
 	(void) ioctl(0, TIOCGWINSZ, (char *)&win);
 	(void) ioctl(slave, TIOCSWINSZ, (char *)&win);
-
-	kill(child, SIGWINCH);
 }
 
 /*

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux