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-07-29 20:24:59 +0400
committerChristopher Faylor <me@cgf.cx>2000-07-29 20:24:59 +0400
commit84c7d4093270dc07de4531ab6648a12daaff77c3 (patch)
tree067ed4cf0bffd057a63b2f472bcab39854f86c17 /winsup/cygwin/external.cc
parent53211514a0466b7e29f6f53c11b769befddfdfa6 (diff)
* include/cygwin/version.h: Bump DLL minor version number to 5 due to all of
the changes below. Redefine process structure to avoid a fixed size table. Redefine pinfo/_pinfo classes. Use these throughout. * dcrt0.cc (dll_crt0_1): Accomodate set_myself argument change. (__api_fatal): Accomodate _pinfo::record_death argument change. * exceptions.cc (really_exit): Ditto. (sig_handle_tty_stop): Use pinfo constructor to access process info. (events_init): Don't create pinfo_mutex since it is no longer required. * external.cc (fillout_pinfo): Use winpids class to iterate over all system pids. (cygwin_internal): lock_pinfo_for_update and unlock_pinfo are now noops. * fhandler_termios.cc (fhandler_termios::set_ctty): Use pinfo constructor to access process info. * fork.cc (fork): Reorganize to initialize child info after the child has started since that is when we know the child's winpid, which is necessary to allocate the pinfo shared memory. * mmap.cc (recreate_mmaps_after_fork): Change arg type to _pinfo. * pinfo.cc: Rename pinfo methods to _pinfo throughout. Eliminate pinfo_list stuff. (set_myself): Accept a pid argument now. Call pinfo initializer to initialize myself. Detect when this is an "execed" process and create an "indirect" pid block. (pinfo_init): Accomodate set_myself arg change. (procinfo): Remove. (pinfo::lock_pinfo): Remove. (pinfo::unlock_pinfo): Remove. (pinfo::init): New method. Allocates shared memory space for process pinfo structure. (pinfo::record_death): Don't call locking functions. (cygwin_winpid_to_pid): Simplify by using new pinfo constructor. (EnumProcessesW95): New function for iterating over processes on Windows 95. (winpids::winpids): New constructor for winpids class. Sets up a list of process ids. (enum_init): Initialize w95/wnt pid enumerators. * shared.cc (shared-info::initialize): Remove pid initialization. * shared.h: Move pinfo stuff into pinfo.h. (class shared_info): Remove pinfo_list element. * signal.cc (kill_worker): Use pinfo constructor to access process info. (kill_pgrp): Ditto. Use winpids methods to access list of processes. * sigproc.cc: Throughout, modify to use _pinfo where appropriate. (proc_exists (pid_t)): New function. Determines if a process exists based on the pid. (proc_exists (_pinfo *p): Use new proc_exists function above. (proc_subproc): Copy pinfo stuff around rather than _pinfo pointers. Try to be careful about releasing shared memory when we don't need it anymore. Remove pinfo locks. (remove_zombies): Remove pinfo memory when zombie is going away. * sigproc.h: Reflect _pinfo/pinfo changes in sigproc.cc. * spawn.cc (spawn_guts): Eliminate pinfo *child argument. Reorganize to only initialize child pinfo after process has been started and we know the windows pid. (_spawnve): Reflect spawn_guts changes. * syscalls.cc (setpgid): Use pinfo constructor to access process info. (getpgid): Ditto. (internal_getlogin): Use _pinfo. * winsup.h: Eliminate pinfo_mutex. Eliminate spawn_guts declaration since it is static now. Reflect set_myself argument change. * include/sys/cygwin.h: Add some PID_* enums to accomodate new pinfo stuff. * include/cygwin/version.h: Update minor version for cygdrive changes below.
Diffstat (limited to 'winsup/cygwin/external.cc')
-rw-r--r--winsup/cygwin/external.cc96
1 files changed, 62 insertions, 34 deletions
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index f187d9779..f31d34938 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -13,53 +13,80 @@ details. */
#include "winsup.h"
static external_pinfo *
-fillout_pinfo (DWORD pid)
+fillout_pinfo (pid_t pid, int winpid)
{
BOOL nextpid;
- pinfo *p = NULL;
- int i;
static external_pinfo ep;
if ((nextpid = !!(pid & CW_NEXTPID)))
pid ^= CW_NEXTPID;
- for (i = 0; i < cygwin_shared->p.size(); i++, p = NULL)
+
+ static winpids pids (0);
+
+ if (!pids.npids)
+ pids.init ();
+
+ memset (&ep, 0, sizeof ep);
+ for (unsigned i = 0; i < pids.npids; i++)
{
- p = cygwin_shared->p.vec + i;
- if (!pid || (DWORD) p->pid == pid)
+ if (!pids[i])
+ continue;
+ pinfo p (pids[i]);
+ pid_t thispid;
+
+ if (p)
+ thispid = p->pid;
+ else if (winpid)
+ thispid = pids[i];
+ else
+ continue;
+
+ if (!pid || thispid == 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))
- 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 (p == NULL)
- return 0;
-
- memset (&ep, 0, sizeof ep);
- 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.dwSpawnedProcessId = p->dwSpawnedProcessId;
- 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;
+ if (!ep.pid)
+ {
+ pids.reset ();
+ return 0;
+ }
return &ep;
}
@@ -80,11 +107,9 @@ cygwin_internal (cygwin_getinfo_types t, ...)
switch (t)
{
case CW_LOCK_PINFO:
- return lock_pinfo_for_update (va_arg (arg, DWORD));
- break;
+ return 1;
case CW_UNLOCK_PINFO:
- unlock_pinfo ();
return 1;
case CW_GETTHREADNAME:
@@ -98,7 +123,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
}
case CW_GETPINFO:
- return (DWORD) fillout_pinfo (va_arg (arg, DWORD));
+ return (DWORD) fillout_pinfo (va_arg (arg, DWORD), 0);
case CW_GETVERSIONINFO:
return (DWORD) cygwin_version_strings;
@@ -122,6 +147,9 @@ cygwin_internal (cygwin_getinfo_types t, ...)
return get_cygdrive_prefixes (user, system);
}
+ case CW_GETPINFO_FULL:
+ return (DWORD) fillout_pinfo (va_arg (arg, pid_t), 1);
+
default:
return (DWORD) -1;
}