From owner-svn-src-all@freebsd.org Sat Jun 9 23:08:03 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56DC7101B53D; Sat, 9 Jun 2018 23:08:03 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C61E7D0DC; Sat, 9 Jun 2018 23:08:03 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E196A245DA; Sat, 9 Jun 2018 23:08:02 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w59N82Fv081475; Sat, 9 Jun 2018 23:08:02 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w59N82Y9081474; Sat, 9 Jun 2018 23:08:02 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806092308.w59N82Y9081474@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 9 Jun 2018 23:08:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334901 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334901 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jun 2018 23:08:03 -0000 Author: eadler Date: Sat Jun 9 23:08:02 2018 New Revision: 334901 URL: https://svnweb.freebsd.org/changeset/base/334901 Log: top(1): handle specific pids better When told to watch a specific pid, don't filter idle, system, or self processes. The summary at the top will still flip correctly though. Modified: head/usr.bin/top/machine.c head/usr.bin/top/top.c Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sat Jun 9 23:07:32 2018 (r334900) +++ head/usr.bin/top/machine.c Sat Jun 9 23:08:02 2018 (r334901) @@ -841,11 +841,11 @@ get_process_info(struct system_info *si, struct proces /* not in use */ continue; - if (!sel->self && pp->ki_pid == mypid) + if (!sel->self && pp->ki_pid == mypid && sel->pid == -1) /* skip self */ continue; - if (!sel->system && (pp->ki_flag & P_SYSTEM)) + if (!sel->system && (pp->ki_flag & P_SYSTEM) && sel->pid == -1) /* skip system process */ continue; @@ -861,7 +861,7 @@ get_process_info(struct system_info *si, struct proces /* skip zombies */ continue; - if (!sel->kidle && pp->ki_tdflags & TDF_IDLETD) + if (!sel->kidle && pp->ki_tdflags & TDF_IDLETD && sel->pid == -1) /* skip kernel idle process */ continue; Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sat Jun 9 23:07:32 2018 (r334900) +++ head/usr.bin/top/top.c Sat Jun 9 23:08:02 2018 (r334901) @@ -259,7 +259,6 @@ main(int argc, char *argv[]) char *order_name = NULL; int order_index = 0; fd_set readfds; - char old_system = false; static const char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwopT"; /* these defines enumerate the "strchr"s of the commands in command_chars */ @@ -381,7 +380,6 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid case 'S': /* show system processes */ ps.system = true; - old_system = true; break; case 'I': /* show idle processes */ @@ -1086,7 +1084,6 @@ restart: break; case CMD_viewsys: ps.system = !ps.system; - old_system = ps.system; break; case CMD_showargs: fmt_flags ^= FMT_SHOWARGS; @@ -1193,7 +1190,6 @@ restart: if (tempbuf2[0] == '+' && tempbuf2[1] == '\0') { ps.pid = (pid_t)-1; - ps.system = old_system; } else { unsigned long long num; const char *errstr; @@ -1206,10 +1202,7 @@ restart: tempbuf2); no_command = true; } else { - if (ps.system == false) - old_system = false; ps.pid = (pid_t)num; - ps.system = true; } } putchar('\r');