* external.cc (cygwin_internal): Implement CW_CMDLINE.
* pinfo.h (SIGCOMMUNE): New signal type. (commune_result): New structure for commune functions. (picom): New enum for commune functions. (_pinfo::hello_pid): New. Pid who's communicating with me. (_pinfo::tothem): New. Handle of communicating pipe. (_pinfo::fromthem): Ditto. (_pinfo::commune_recv): Declare. (_pinfo::commune_send): Declare. (_pinfo::alive): Declare. (_pinfo::cmdline): Declare. (_pinfo::lock): Declare. * pinfo.cc (set_myself): Initialize new _pinfo lock. (_pinfo::alive): Define. Determines if process still exists. (_pinfo::commune_recv): Define. Receive info from another cooperating process. (_pinfo::commune_send): Define. Send info to another cooperating process. (_pinfo::cmdline): Define. Determine command line of a given process. * include/sys/cygwin.h (CW_CMDLINE): Define. *sigproc.cc (talktome): Communicate with any processes who want to talk to me. (wait_sig): Honor __SIGCOMMUNE. * fhandler.cc (fhandler_virtual::fixup_after_exec): Declare. * fhandler_proc.cc: Use malloc/free/realloc throughout rather than cmalloc since buffers don't need to be propagated to subprocesses. * fhandler_registry.cc: Ditto. * fhandler_virtual.cc: Ditto. (fhandler_virtual::fixup_after_exec): Define. * fhandler_process.cc: Ditto for malloc/free/realloc. (process_listin): Add "cmdline". (fhandler_process::fill_filebuf): Implement PROCESS_CMDLINE. * miscfuncs.cc (isalpha_array): New array populated with xor values for alpha characters to switch from one case to another. * string.h (cygwin_strcasematch): New asm implementation of case match. * string.h (cygwin_nstrcasematch): New asm implementation of counted case match.
This commit is contained in:
@ -42,6 +42,7 @@ static const int PROCESS_SID = 10;
|
||||
static const int PROCESS_CTTY = 11;
|
||||
static const int PROCESS_STAT = 12;
|
||||
static const int PROCESS_STATM = 13;
|
||||
static const int PROCESS_CMDLINE = 14;
|
||||
|
||||
static const char * const process_listing[] =
|
||||
{
|
||||
@ -59,6 +60,7 @@ static const char * const process_listing[] =
|
||||
"ctty",
|
||||
"stat",
|
||||
"statm",
|
||||
"cmdline",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -264,8 +266,7 @@ fhandler_process::fill_filebuf ()
|
||||
case PROCESS_CTTY:
|
||||
case PROCESS_PPID:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 40);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = 40);
|
||||
int num;
|
||||
switch (fileid)
|
||||
{
|
||||
@ -295,10 +296,18 @@ fhandler_process::fill_filebuf ()
|
||||
filesize = strlen (filebuf);
|
||||
break;
|
||||
}
|
||||
case PROCESS_CMDLINE:
|
||||
{
|
||||
if (filebuf)
|
||||
free (filebuf);
|
||||
filebuf = p->cmdline (filesize);
|
||||
if (!*filebuf)
|
||||
filebuf = strdup ("<defunct>");
|
||||
break;
|
||||
}
|
||||
case PROCESS_EXENAME:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = MAX_PATH);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = MAX_PATH);
|
||||
if (p->process_state & (PID_ZOMBIE | PID_EXITED))
|
||||
strcpy (filebuf, "<defunct>");
|
||||
else
|
||||
@ -317,8 +326,7 @@ fhandler_process::fill_filebuf ()
|
||||
}
|
||||
case PROCESS_WINPID:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 40);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = 40);
|
||||
__small_sprintf (filebuf, "%d\n", p->dwProcessId);
|
||||
filesize = strlen (filebuf);
|
||||
break;
|
||||
@ -326,8 +334,7 @@ fhandler_process::fill_filebuf ()
|
||||
case PROCESS_WINEXENAME:
|
||||
{
|
||||
int len = strlen (p->progname);
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = (len + 2));
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = (len + 2));
|
||||
strcpy (filebuf, p->progname);
|
||||
filebuf[len] = '\n';
|
||||
filesize = len + 1;
|
||||
@ -335,22 +342,19 @@ fhandler_process::fill_filebuf ()
|
||||
}
|
||||
case PROCESS_STATUS:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 2048);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_status (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROCESS_STAT:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 2048);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_stat (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROCESS_STATM:
|
||||
{
|
||||
if (!filebuf)
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc = 2048);
|
||||
filebuf = (char *) realloc (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_statm (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user