Cygwin: processes: fix handling of native Windows processes
Since commit b5e1003722
, native
Windows processes not started by Cygwin processes don't have a
Cygwin PID anymore. This breaks ps -W and kill -f <WINPID>.
Introduce MAX_PID (65536 for now).
Cygwin processes as well as native Windows processes started
from a Cygwin process get a PID < MAX_PID. All other native
Windows processes get a faked Cygwin PID >= MAX_PID.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
231ad6941f
commit
448cf5aa4b
|
@ -63,19 +63,23 @@ fillout_pinfo (pid_t pid, int winpid)
|
|||
_pinfo *p = pids[i];
|
||||
i++;
|
||||
|
||||
/* Native Windows process not started from Cygwin have no procinfo
|
||||
attached. They don't have a real Cygwin PID either. We fake a
|
||||
Cygwin PID beyond MAX_PID. */
|
||||
if (!p)
|
||||
{
|
||||
if (!nextpid && thispid != (DWORD) pid)
|
||||
if (!nextpid && thispid + MAX_PID != (DWORD) pid)
|
||||
continue;
|
||||
ep.pid = cygwin_pid (thispid);
|
||||
ep.pid = thispid + MAX_PID;
|
||||
ep.dwProcessId = thispid;
|
||||
ep.process_state = PID_IN_USE;
|
||||
ep.ctty = -1;
|
||||
break;
|
||||
}
|
||||
else if (nextpid || p->pid == pid || (winpid && thispid == (DWORD) pid))
|
||||
else if (nextpid || p->pid == pid)
|
||||
{
|
||||
ep.ctty = (p->ctty < 0 || iscons_dev (p->ctty)) ? p->ctty : device::minor (p->ctty);
|
||||
ep.ctty = (p->ctty < 0 || iscons_dev (p->ctty))
|
||||
? p->ctty : device::minor (p->ctty);
|
||||
ep.pid = p->pid;
|
||||
ep.ppid = p->ppid;
|
||||
ep.dwProcessId = p->dwProcessId;
|
||||
|
|
|
@ -241,7 +241,7 @@ create_cygwin_pid ()
|
|||
do
|
||||
{
|
||||
pid = ((uint32_t) InterlockedIncrement (&cygwin_shared->pid_src))
|
||||
% 65536;
|
||||
% MAX_PID;
|
||||
}
|
||||
while (pid < 2);
|
||||
__small_swprintf (sym_name, L"cygpid.%u", pid);
|
||||
|
|
|
@ -211,6 +211,8 @@ private:
|
|||
DWORD status_exit (DWORD);
|
||||
};
|
||||
|
||||
#define MAX_PID 65536
|
||||
|
||||
#define ISSTATE(p, f) (!!((p)->process_state & f))
|
||||
#define NOTSTATE(p, f) (!((p)->process_state & f))
|
||||
|
||||
|
|
Loading…
Reference in New Issue