* ps.cc (main): Don't overwrite process name, just attach <defunct>

to it for zombie processes.
This commit is contained in:
Corinna Vinschen 2011-08-10 19:52:41 +00:00
parent d10f0e106e
commit 56a85b9cea
2 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2011-08-10 Corinna Vinschen <corinna@vinschen.de>
* ps.cc (main): Don't overwrite process name, just attach <defunct>
to it for zombie processes.
2011-07-19 Yaakov Selkowitz <yselkowitz@users.sourceforge.net> 2011-07-19 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* Makefile.in (CYGWIN_BINS): Add getconf. * Makefile.in (CYGWIN_BINS): Add getconf.

View File

@ -1,7 +1,7 @@
/* ps.cc /* ps.cc
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 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. 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 /* Maximum possible path length under NT. There's no official define
for that value. */ for that value. */
char pname[NT_MAX_PATH]; char pname[NT_MAX_PATH + sizeof (" <defunct>")];
if (p->process_state & PID_EXITED || (p->exitcode & ~0xffff)) if (p->ppid)
strcpy (pname, "<defunct>");
else if (p->ppid)
{ {
char *s; char *s;
pname[0] = '\0'; pname[0] = '\0';
@ -413,6 +411,8 @@ main (int argc, char *argv[])
s = strchr (pname, '\0') - 4; s = strchr (pname, '\0') - 4;
if (s > pname && strcasecmp (s, ".exe") == 0) if (s > pname && strcasecmp (s, ".exe") == 0)
*s = '\0'; *s = '\0';
if (p->process_state & PID_EXITED || (p->exitcode & ~0xffff))
strcat (pname, " <defunct>");
} }
else if (query == CW_GETPINFO_FULL) else if (query == CW_GETPINFO_FULL)
{ {