Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/lock PR/24796: Colin Percival: CPU-eating loop in lo...



details:   https://anonhg.NetBSD.org/src/rev/e25db99e8829
branches:  trunk
changeset: 559434:e25db99e8829
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 17 17:01:31 2004 +0000

description:
PR/24796: Colin Percival: CPU-eating loop in lock(1); apply FreeBSD fix.

diffstat:

 usr.bin/lock/lock.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 652dc484e3ce -r e25db99e8829 usr.bin/lock/lock.c
--- a/usr.bin/lock/lock.c       Wed Mar 17 17:00:34 2004 +0000
+++ b/usr.bin/lock/lock.c       Wed Mar 17 17:01:31 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.c,v 1.21 2003/08/07 11:14:22 agc Exp $    */
+/*     $NetBSD: lock.c,v 1.22 2004/03/17 17:01:31 christos Exp $       */
 
 /*
  * Copyright (c) 1980, 1987, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)lock.c     8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: lock.c,v 1.21 2003/08/07 11:14:22 agc Exp $");
+__RCSID("$NetBSD: lock.c,v 1.22 2004/03/17 17:01:31 christos Exp $");
 #endif /* not lint */
 
 /*
@@ -61,6 +61,7 @@
 #include <ctype.h>
 #include <err.h>
 #include <pwd.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -206,7 +207,7 @@
                if (!fgets(s, sizeof(s), stdin)) {
                        clearerr(stdin);
                        hi(0);
-                       continue;
+                       goto tryagain;
                }
                if (usemine) {
                        s[strlen(s) - 1] = '\0';
@@ -222,7 +223,8 @@
                else if (!strcmp(s, s1))
                        break;
                (void)printf("\a\n");
-               if (tcsetattr(0, TCSADRAIN, &ntty) < 0)
+tryagain:
+               if (tcsetattr(0, TCSADRAIN, &ntty) == -1 && errno != EINTR)
                        exit(1);
        }
        quit(0);



Home | Main Index | Thread Index | Old Index