From owner-freebsd-hackers@freebsd.org Tue Apr 21 21:09:51 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9322E2BAD19 for ; Tue, 21 Apr 2020 21:09:51 +0000 (UTC) (envelope-from ypankov@fastmail.com) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 496GRL4QfNz4D9w for ; Tue, 21 Apr 2020 21:09:50 +0000 (UTC) (envelope-from ypankov@fastmail.com) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id DB7E15C0139 for ; Tue, 21 Apr 2020 17:09:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 21 Apr 2020 17:09:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= to:from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=fm2; bh=zvGkD6xTvWxrHPHBFAcmdamKlo J3pQD/Q8X/p+P3YQQ=; b=bD7Hp3u9tHov2dlHcsUMuDMP0b8ApvMUwxaOnNMCzV EnD1XUc0A1AX2CgXjW6hPceTpURnQjwVWjcf+g3JnFvGFtD3H5QSbKkqpflnd/CM 2x+EiQabo52i1fghV/dAoaUxJJMBZKqYsdezeUixjUHH87Lo1Ytu3QNB2J6Rdcw4 9IbXfcv+Pvk82nqB+o3Ju3cb27+wD4wNqBu0WJ0TNn09S3mCwEJ5okB4AZg/BXqp NkJ6NgG05Dl4Xux8HyUTlsefhWso/fn5BLUgfl3yb9fldXkBoiRbDIIy+A9oLM9O 8DhBE62jvmQsyChhmlRvWTcWM0xMhU6LfRJmUSZJ6ehg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=zvGkD6 xTvWxrHPHBFAcmdamKloJ3pQD/Q8X/p+P3YQQ=; b=Hgioug7uYQSC7qmReiMBfw U9ez7+rF0PFNDW+FqOVJLNvjSdMOEkC3vvOcwDM4Y0pMjS/0+l0BS8YDWOxWl+OE hn0Igzu7M3xsw9vglrR5ju/dyc7EGDkcNwpivx2i1idXduRsMUBnRMyHZNg7hGPr +g/5L/cqRk0DWTEBto0SxyRDZ6FE+l+P7S11WFJq3S5Zr7Uss4YdzJaswxke2xTc E+hm9RR7c6i7C07uhPPEO53MTvYT88rvPwmTfoO62HjBysslmHepsFkDrdojyEMr guKjkh6hMCayMfXdp5fzQgVVrtd6SFL2Z9Ans41S4aQeQoQMfwvlJRoAtNj5zedg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrgeehgdduheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefvhffukffffgggtgfgsehtjeertd dtfeejnecuhfhrohhmpegjuhhrihcurfgrnhhkohhvuceohihprghnkhhovhesfhgrshht mhgrihhlrdgtohhmqeenucfkphepkeehrddujeehrddukeeirdduleeknecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhephihprghnkhhovhesfhgr shhtmhgrihhlrdgtohhm X-ME-Proxy: Received: from [192.168.1.6] (unknown [85.175.186.198]) by mail.messagingengine.com (Postfix) with ESMTPA id 61C5E3280059 for ; Tue, 21 Apr 2020 17:09:49 -0400 (EDT) To: freebsd-hackers@freebsd.org From: Yuri Pankov Subject: "most interesting" process in w(1) Message-ID: Date: Wed, 22 Apr 2020 00:09:48 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 496GRL4QfNz4D9w X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=fastmail.com header.s=fm2 header.b=bD7Hp3u9; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=Hgioug7u; dmarc=pass (policy=none) header.from=fastmail.com; spf=pass (mx1.freebsd.org: domain of ypankov@fastmail.com designates 66.111.4.28 as permitted sender) smtp.mailfrom=ypankov@fastmail.com X-Spamd-Result: default: False [-3.10 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[28.4.111.66.rep.mailspike.net : 127.0.0.18]; R_SPF_ALLOW(-0.20)[+ip4:66.111.4.28]; FREEMAIL_FROM(0.00)[fastmail.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[fastmail.com:+,messagingengine.com:+]; DMARC_POLICY_ALLOW(-0.50)[fastmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; IP_SCORE(0.00)[ip: (-9.82), ipnet: 66.111.4.0/24(-4.89), asn: 11403(-2.69), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[28.4.111.66.list.dnswl.org : 127.0.5.1]; ASN(0.00)[asn:11403, ipnet:66.111.4.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[198.186.175.85.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[fastmail.com]; R_DKIM_ALLOW(-0.20)[fastmail.com:s=fm2,messagingengine.com:s=fm2]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Apr 2020 21:09:51 -0000 Looking at how w(1) finds "most interesting" process for terminal, I noticed the following code which looks strange to me (usr.bin/w/w.c, line 360 in HEAD) for (ep = ehead; ep != NULL; ep = ep->next) { if (ep->tdev == kp->ki_tdev) { /* * proc is associated with this terminal */ if (ep->kp == NULL && kp->ki_pgid == kp->ki_tpgid) { /* * Proc is 'most interesting' */ if (proc_compare(ep->kp, kp)) ep->kp = kp; ... } } } Given the (ep->kp == NULL) check, proc_compare() becomes no-op, it will always select kp, and that's the only place we ever set ep->kp, so the first matching process is always "most interesting". If that's really what we want, we could do without the proc_compare() call. What am I missing here?