From 56a85b9ceacc14be33d83b40ee1cab94e71b5f43 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 10 Aug 2011 19:52:41 +0000 Subject: [PATCH] * ps.cc (main): Don't overwrite process name, just attach to it for zombie processes. --- winsup/utils/ChangeLog | 5 +++++ winsup/utils/ps.cc | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index c1714fa22..1b95df500 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2011-08-10 Corinna Vinschen + + * ps.cc (main): Don't overwrite process name, just attach + to it for zombie processes. + 2011-07-19 Yaakov Selkowitz * Makefile.in (CYGWIN_BINS): Add getconf. diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc index fe8138dc1..3a55f497a 100644 --- a/winsup/utils/ps.cc +++ b/winsup/utils/ps.cc @@ -1,7 +1,7 @@ /* ps.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2008, 2009, 2010 Red Hat, Inc. + 2008, 2009, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -397,10 +397,8 @@ main (int argc, char *argv[]) /* Maximum possible path length under NT. There's no official define for that value. */ - char pname[NT_MAX_PATH]; - if (p->process_state & PID_EXITED || (p->exitcode & ~0xffff)) - strcpy (pname, ""); - else if (p->ppid) + char pname[NT_MAX_PATH + sizeof (" ")]; + if (p->ppid) { char *s; pname[0] = '\0'; @@ -413,6 +411,8 @@ main (int argc, char *argv[]) s = strchr (pname, '\0') - 4; if (s > pname && strcasecmp (s, ".exe") == 0) *s = '\0'; + if (p->process_state & PID_EXITED || (p->exitcode & ~0xffff)) + strcat (pname, " "); } else if (query == CW_GETPINFO_FULL) {