Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Koppe <andy.koppe@gmail.com>2022-11-09 23:34:30 +0300
committerCorinna Vinschen <corinna@vinschen.de>2022-11-10 12:07:05 +0300
commit59b8ee7d7066b9a3f39e1c765d0cecb5d9bc07fd (patch)
treeecc1ae797960ff6b3f0c4a5209e6b30ad9e5f516
parent67459ce679f42ef81faaeb2401593105d6fbbf5d (diff)
Cygwin: Correct /proc/*/stat for processes without ctty
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.
-rw-r--r--winsup/cygwin/fhandler/process.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler/process.cc b/winsup/cygwin/fhandler/process.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 = 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 = (((p->ctty >> 8) & 0xff) << 20)
- | (((p->ctty >> 16) & 0xfff) << 8)
- | (p->ctty & 0xff);
+ int tty_nr = 0;
+ if (p->ctty > 0)
+ tty_nr = (((p->ctty >> 8) & 0xff) << 20)
+ | (((p->ctty >> 16) & 0xfff) << 8)
+ | (p->ctty & 0xff);
if (p->process_state & PID_EXITED)
strcpy (cmd, "<defunct>");