diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 47656e90a..de0c56033 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,10 @@ +2007-12-06 Corinna Vinschen + + * ps.cc: Include limits.h. + (main): Set file name buffer size to PATH_MAX. Use progname or + progname_long member of struct external_pinfo dependent of the value of + the struct's version member. + 2007-08-31 Dave Korn * mkgroup.c (enum_groups): Use MAX_PREFERRED_LENGTH in netgroupenum diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc index 651175144..2a0ef01c8 100644 --- a/winsup/utils/ps.cc +++ b/winsup/utils/ps.cc @@ -15,6 +15,7 @@ details. */ #include #include #include +#include #include #include #include @@ -354,14 +355,17 @@ main (int argc, char *argv[]) else if (p->process_state & PID_TTYOU) status = 'O'; - char pname[MAX_PATH]; + char pname[PATH_MAX]; if (p->process_state & PID_EXITED || (p->exitcode & ~0xffff)) strcpy (pname, ""); else if (p->ppid) { char *s; pname[0] = '\0'; - cygwin_conv_to_posix_path (p->progname, pname); + if (p->version >= EXTERNAL_PINFO_VERSION_32_LP) + cygwin_conv_to_posix_path (p->progname_long, pname); + else + cygwin_conv_to_posix_path (p->progname, pname); s = strchr (pname, '\0') - 4; if (s > pname && strcasecmp (s, ".exe") == 0) *s = '\0'; @@ -376,7 +380,7 @@ main (int argc, char *argv[]) DWORD n = p->dwProcessId; if (!myEnumProcessModules (h, hm, sizeof (hm), &n)) n = 0; - if (!n || !myGetModuleFileNameEx (h, hm[0], pname, MAX_PATH)) + if (!n || !myGetModuleFileNameEx (h, hm[0], pname, PATH_MAX)) strcpy (pname, "*** unknown ***"); FILETIME ct, et, kt, ut; if (GetProcessTimes (h, &ct, &et, &kt, &ut))