From owner-freebsd-bugs@FreeBSD.ORG Tue Jul 1 12:40:04 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0BB6106564A for ; Tue, 1 Jul 2008 12:40:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C21B98FC1B for ; Tue, 1 Jul 2008 12:40:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m61Ce4uc082076 for ; Tue, 1 Jul 2008 12:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m61Ce4Eq082075; Tue, 1 Jul 2008 12:40:04 GMT (envelope-from gnats) Date: Tue, 1 Jul 2008 12:40:04 GMT Message-Id: <200807011240.m61Ce4Eq082075@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jaakko Heinonen Cc: Subject: Re: bin/125098: ee(1) consume 100% cpu usage X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jaakko Heinonen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jul 2008 12:40:04 -0000 The following reply was made to PR bin/125098; it has been noted by GNATS. From: Jaakko Heinonen To: bug-followup@FreeBSD.org, strldd@strijd.homeunix.net Cc: Subject: Re: bin/125098: ee(1) consume 100% cpu usage Date: Tue, 1 Jul 2008 15:31:36 +0300 --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This is similar to the bug bin/107171 seen in systat(1). The bug happens because after closing the terminal subsequent wgetch() calls fail but ee(1) ignores errors and thus hangs to infinite loop. Normally ee(1) dies correctly on terminal close when it receives SIGHUP. However when you run it as different user (root) it doesn't receive SIGHUP. Attached patch should fix the problem. -- Jaakko --pf9I7BMVVzbSWLtt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ee-hang-on-getch.diff" Index: usr.bin/ee/ee.c =================================================================== --- usr.bin/ee/ee.c (revision 180121) +++ usr.bin/ee/ee.c (working copy) @@ -622,7 +622,10 @@ doupdate(); in = wgetch(text_win); if (in == -1) - continue; + if (errno == EINTR) + continue; + else + edit_abort(0); resize_check(); @@ -1869,7 +1872,10 @@ esc_flag = FALSE; in = wgetch(com_win); if (in == -1) - continue; + if (errno == EINTR) + continue; + else + edit_abort(0); if (((in == 8) || (in == 127) || (in == KEY_BACKSPACE)) && (g_pos > 0)) { tmp_int = g_horz; @@ -1894,7 +1900,10 @@ esc_flag = TRUE; in = wgetch(com_win); if (in == -1) - continue; + if (errno == EINTR) + continue; + else + edit_abort(0); } *nam_str = in; g_pos++; @@ -3386,6 +3395,11 @@ wrefresh(temp_win); input = wgetch(temp_win); + if (input == -1) + if (errno == EINTR) + continue; + else + edit_abort(0); if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) || ((input >= '0') && (input <= '9'))) --pf9I7BMVVzbSWLtt--