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:
authorCorinna Vinschen <corinna@vinschen.de>2007-12-03 17:13:03 +0300
committerCorinna Vinschen <corinna@vinschen.de>2007-12-03 17:13:03 +0300
commit814066b9120c6884d45665da6ca926e20cbaaf7c (patch)
tree8818db9a29acbf9f0fb59f27b720b82387ab20d9 /winsup/cygwin/fhandler_process.cc
parent268e8d00e9c0d44c9863c66c617e4f50d67c55ad (diff)
* autoload.cc (GetModuleFileNameExW): Replace definition of
GetModuleFileNameExA. * fhandler_process.cc (format_process_maps): Change modname type to WCHAR. Set buffer sizes to PATH_MAX. Call GetModuleFileNameExW instead of GetModuleFileNameExA. Call mount_info::conv_to_posix_path instead of cygwin_conv_to_full_posix_path. Set posix_modname to modname if that call fails. (format_process_stat): Set cmd buffer size to NAME_MAX + 1. Simplify setting cmd to process name. (format_process_status): Ditto. * path.cc (mount_info::conv_to_posix_path): Call sys_wcstombs correctly.
Diffstat (limited to 'winsup/cygwin/fhandler_process.cc')
-rw-r--r--winsup/cygwin/fhandler_process.cc25
1 files changed, 11 insertions, 14 deletions
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 758c34d3e..916c0dbf3 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -524,8 +524,8 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
DWORD_PTR wset_size;
DWORD_PTR *workingset = NULL;
MODULEINFO info;
- char modname[CYG_MAX_PATH];
- char posix_modname[CYG_MAX_PATH];
+ WCHAR modname[PATH_MAX];
+ char posix_modname[PATH_MAX];
if (!EnumProcessModules (proc, NULL, 0, &needed))
{
@@ -551,12 +551,13 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
}
for (i = 0; i < needed / sizeof (HMODULE); i++)
if (GetModuleInformation (proc, modules[i], &info, sizeof info)
- && GetModuleFileNameEx (proc, modules[i], modname, sizeof modname))
+ && GetModuleFileNameExW (proc, modules[i], modname, sizeof modname))
{
char access[5];
strcpy (access, "r--p");
struct __stat64 st;
- cygwin_conv_to_full_posix_path (modname, posix_modname);
+ if (mount_table->conv_to_posix_path (modname, posix_modname, 0))
+ sys_wcstombs (posix_modname, PATH_MAX, modname);
if (stat64 (posix_modname, &st))
{
st.st_dev = 0;
@@ -600,7 +601,7 @@ out:
static _off64_t
format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
{
- char cmd[CYG_MAX_PATH];
+ char cmd[NAME_MAX + 1];
int state = 'R';
unsigned long fault_count = 0UL,
utime = 0UL, stime = 0UL,
@@ -611,10 +612,8 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>");
else
{
- strcpy (cmd, p->progname);
- char *last_slash = strrchr (cmd, '\\');
- if (last_slash != NULL)
- strcpy (cmd, last_slash + 1);
+ char *last_slash = strrchr (p->progname, '\\');
+ strcpy (cmd, last_slash ? last_slash + 1 : p->progname);
int len = strlen (cmd);
if (len > 4)
{
@@ -730,7 +729,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
static _off64_t
format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
{
- char cmd[CYG_MAX_PATH];
+ char cmd[NAME_MAX + 1];
int state = 'R';
const char *state_str = "unknown";
unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL,
@@ -739,10 +738,8 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>");
else
{
- strcpy (cmd, p->progname);
- char *last_slash = strrchr (cmd, '\\');
- if (last_slash != NULL)
- strcpy (cmd, last_slash + 1);
+ char *last_slash = strrchr (p->progname, '\\');
+ strcpy (cmd, last_slash ? last_slash + 1 : p->progname);
int len = strlen (cmd);
if (len > 4)
{