From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 3B67C3858D20; Thu, 10 Nov 2022 09:09:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B67C3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668071354; bh=fOLXyfGO3CnBc3gCaFIsBj3A8u86ZKd18tpbSLcPDyg=; h=From:To:Subject:Date:From; b=oWrSbMJG9X3oEhWmrRHpCP300QIlffH1u4q7UJhT/pM2sTNuAY2susQaS8gI09B7O 44aWd+W2UDiyHxXAqv3SjMSVB5/fHYEOq5mJKThkTifikocS0Rh7VkLRiDkxoXgM6h QkG6D8f5bK02Vx5GN3Mzpbqq4Ib3cRqXYh0QuQVg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Correct /proc/*/stat for processes without ctty X-Act-Checkin: newlib-cygwin X-Git-Author: Andy Koppe X-Git-Refname: refs/heads/master X-Git-Oldrev: 67459ce679f42ef81faaeb2401593105d6fbbf5d X-Git-Newrev: 59b8ee7d7066b9a3f39e1c765d0cecb5d9bc07fd Message-Id: <20221110090914.3B67C3858D20@sourceware.org> Date: Thu, 10 Nov 2022 09:09:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D59b8ee7d706= 6b9a3f39e1c765d0cecb5d9bc07fd commit 59b8ee7d7066b9a3f39e1c765d0cecb5d9bc07fd Author: Andy Koppe Date: Wed Nov 9 20:34:30 2022 +0000 Cygwin: Correct /proc/*/stat for processes without ctty =20 Report 0 instead of 268435455 (i.e. 0xFFFFFFF) in the tty field of /proc/*/stat for processes without a controlling terminal. This is what the procps utility expects when selecting or excluding such processes. Diff: --- winsup/cygwin/fhandler/process.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler/process.cc b/winsup/cygwin/fhandler/pro= cess.cc index a8c17f1b0..b0aef2ebe 100644 --- a/winsup/cygwin/fhandler/process.cc +++ b/winsup/cygwin/fhandler/process.cc @@ -1092,9 +1092,11 @@ format_process_stat (void *data, char *&destbuf) int nice =3D 0; /* ctty maj is 31:16, min is 15:0; tty_nr s/b maj 15:8, min 31:20, 7:0; maj is 31:16 >> 16 & fff << 8; min is 15:0 >> 8 & ff << 20 | & ff */ - int tty_nr =3D (((p->ctty >> 8) & 0xff) << 20) - | (((p->ctty >> 16) & 0xfff) << 8) - | (p->ctty & 0xff); + int tty_nr =3D 0; + if (p->ctty > 0) + tty_nr =3D (((p->ctty >> 8) & 0xff) << 20) + | (((p->ctty >> 16) & 0xfff) << 8) + | (p->ctty & 0xff); =20 if (p->process_state & PID_EXITED) strcpy (cmd, "");