From owner-freebsd-bugs@FreeBSD.ORG Tue May 20 10:50:09 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97DF637B401 for ; Tue, 20 May 2003 10:50:09 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C74743FAF for ; Tue, 20 May 2003 10:50:08 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h4KHo8Up094694 for ; Tue, 20 May 2003 10:50:08 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h4KHo8wa094693; Tue, 20 May 2003 10:50:08 -0700 (PDT) Resent-Date: Tue, 20 May 2003 10:50:08 -0700 (PDT) Resent-Message-Id: <200305201750.h4KHo8wa094693@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jilles Tjoelker Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D9D037B401 for ; Tue, 20 May 2003 10:46:18 -0700 (PDT) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 845A243F93 for ; Tue, 20 May 2003 10:46:17 -0700 (PDT) (envelope-from jilles@stack.nl) Received: by mailhost.stack.nl (Postfix, from userid 65534) id 591CC1F00A; Tue, 20 May 2003 19:46:16 +0200 (CEST) Received: from turtle.stack.nl (turtle.stack.nl [2001:610:1108:5010::132]) by mailhost.stack.nl (Postfix) with ESMTP id 5E60E1F006 for ; Tue, 20 May 2003 19:46:11 +0200 (CEST) Received: by turtle.stack.nl (Postfix, from userid 1677) id 4C53E1CC5D; Tue, 20 May 2003 19:46:11 +0200 (CEST) Message-Id: <20030520174611.4C53E1CC5D@turtle.stack.nl> Date: Tue, 20 May 2003 19:46:11 +0200 (CEST) From: Jilles Tjoelker To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/52490: ^T'ing a zombie causes 'calcru: negative time' messages X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 May 2003 17:50:10 -0000 >Number: 52490 >Category: kern >Synopsis: ^T'ing a zombie causes 'calcru: negative time' messages >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue May 20 10:50:08 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Jilles Tjoelker >Release: FreeBSD 5.1-BETA i386 >Organization: >Environment: System: FreeBSD turtle.stack.nl 5.1-BETA FreeBSD 5.1-BETA #10: Mon May 12 15:30:54 CEST 2003 jilles@turtle.stack.nl:/usr/obj/usr/src/sys/TURTLE i386 It occurs on 4.8-RELEASE and many older 4.x versions as well. >Description: When ^T'ing (ttyinfo) a zombie, calcru() is called and logs a 'negative time' message. To achieve this, only zombies must be in the foreground process group of the terminal. >How-To-Repeat: Compile and run the negtime program. Pressing ^T after it has printed the message 'done' causes a log message 'calcru: negative time...'. (It may be necessary to do stty status ^t beforehand.) >Fix: A patch (against 4-STABLE) is attached which prevents calcru() from being called on zombies from ttyinfo(). I don't know in what process states calcru() may be called exactly, but for the rest of /sys/kern it's only used for accounting, exiting and getrusage() and therefore cannot be called on zombies. (Perhaps this is or should be documented somewhere.) --- negtime.c begins here --- /* Copyright (C) 2001 by Jilles Tjoelker */ #include #include #include #include int main(int argc, char *argv[]) { int pid,pgid; if (argc != 1) { fprintf(stderr, "Usage: %s\n", argv[0]); return(1); } switch (pid=fork()) { case 0: signal(SIGTTOU,SIG_IGN); pid=getpid(); pgid=getpgrp(); if (setpgid(pid,pid)==-1) { perror("Error in setpgid()"); _exit(1); } if (tcsetpgrp(0,pid)==-1) { setpgid(pid,pgid); perror("Error in tcsetpgrp()"); _exit(2); } sleep(1); printf("done\n"); _exit(127); break; case -1: fprintf(stderr, "Error in fork().\n"); break; default: sleep(10); } return 0; } /* vim:ts=8:cin:sw=4:kp=man\ -S3\:2\:9\:1\:4\:5\:6\:7\:8\:n */ --- negtime.c ends here --- --- ttyinfo_zombie.patch begins here --- --- /usr/src/sys/kern/tty.c.orig Mon Mar 11 02:32:31 2002 +++ /usr/src/sys/kern/tty.c Sun Jan 19 21:40:16 2003 @@ -2323,7 +2323,7 @@ pick->p_stat == SRUN ? "running" : pick->p_wmesg ? pick->p_wmesg : "iowait"); - if (pick->p_flag & P_INMEM) { + if (pick->p_flag & P_INMEM && pick->p_stat != SZOMB) { calcru(pick, &utime, &stime, NULL); /* Print user time. */ --- ttyinfo_zombie.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: