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:
authorChristopher Faylor <me@cgf.cx>2000-08-26 05:36:20 +0400
committerChristopher Faylor <me@cgf.cx>2000-08-26 05:36:20 +0400
commit3c2c374555e45b55f0fdc6f1c37257bc631cf5ab (patch)
tree73f97864758c82b21151cb456ce9666cab91da2a /winsup/cygwin/external.cc
parent14d3488d1f45a6ac4fffd4e3ab891f5b9d2ffac9 (diff)
* dcrt0.cc (dll_crt0_1): Move set_os_type.
(_dll_crt0): To here. (cygwin_dll_init): And here. * external.cc (fillout_pinfo): Use more foolproof method for scanning for pids. * pinfo.cc (set_myself): Eliminate myself_identity.init. * sigproc.cc (wait_sig): Do it here instead to reduce the amount of time where there could potentially be two processes with the same pid. * spawn.cc (spawn_guts): Eliminate duplicate initialization. * include/sys/cygwin.h: Mark unused PID_* elements.
Diffstat (limited to 'winsup/cygwin/external.cc')
-rw-r--r--winsup/cygwin/external.cc86
1 files changed, 38 insertions, 48 deletions
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index 566293b63..16303f56e 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -31,64 +31,54 @@ fillout_pinfo (pid_t pid, int winpid)
if (!pids.npids)
pids.init ();
+ static unsigned int i = 0;
+ if (!pid)
+ i = 0;
+
memset (&ep, 0, sizeof ep);
- for (unsigned i = 0; i < pids.npids; i++)
+ for (; i < pids.npids; )
{
- if (!pids[i])
- continue;
- pinfo p (pids[i]);
- pid_t thispid;
-
- if (p)
- thispid = p->pid;
- else if (winpid)
- thispid = pids[i];
- else
+ DWORD thispid = pids[i++];
+ if (!thispid)
continue;
+ pinfo p (thispid);
- if (!pid || thispid == pid)
+ if (!p)
+ {
+ if (!winpid)
+ continue;
+ ep.pid = thispid;
+ ep.dwProcessId = cygwin_pid (thispid);
+ ep.process_state = PID_IN_USE;
+ ep.ctty = -1;
+ }
+ else if (p->pid)
{
- if (nextpid && pid)
- {
- pid = 0;
- nextpid = 0;
- continue;
- }
-
- if (!p)
- {
- ep.pid = pids[i];
- ep.dwProcessId = cygwin_pid (pids[i]);
- ep.process_state = PID_IN_USE;
- ep.ctty = -1;
- }
- else if (p->pid && NOTSTATE(p, PID_CLEAR))
- {
- ep.ctty = tty_attached (p) ? p->ctty : -1;
- ep.pid = p->pid;
- ep.ppid = p->ppid;
- ep.hProcess = p->hProcess;
- ep.dwProcessId = p->dwProcessId;
- ep.uid = p->uid;
- ep.gid = p->gid;
- ep.pgid = p->pgid;
- ep.sid = p->sid;
- ep.umask = p->umask;
- ep.start_time = p->start_time;
- ep.rusage_self = p->rusage_self;
- ep.rusage_children = p->rusage_children;
- strcpy (ep.progname, p->progname);
- ep.strace_mask = 0;
- ep.strace_file = 0;
-
- ep.process_state = p->process_state;
- }
- break;
+ ep.ctty = tty_attached (p) ? p->ctty : -1;
+ ep.pid = p->pid;
+ ep.ppid = p->ppid;
+ ep.hProcess = p->hProcess;
+ ep.dwProcessId = p->dwProcessId;
+ ep.uid = p->uid;
+ ep.gid = p->gid;
+ ep.pgid = p->pgid;
+ ep.sid = p->sid;
+ ep.umask = p->umask;
+ ep.start_time = p->start_time;
+ ep.rusage_self = p->rusage_self;
+ ep.rusage_children = p->rusage_children;
+ strcpy (ep.progname, p->progname);
+ ep.strace_mask = 0;
+ ep.strace_file = 0;
+
+ ep.process_state = p->process_state;
}
+ break;
}
if (!ep.pid)
{
+ i = 0;
pids.reset ();
return 0;
}