diff options
author | Christopher Faylor <me@cgf.cx> | 2000-10-16 23:55:58 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-10-16 23:55:58 +0000 |
commit | 166b2571ce446b4085d4c2067b0d0d36c608f131 (patch) | |
tree | 097f18452160a8058924634fa52d5e454e8dfe9e /winsup/cygwin/pinfo.cc | |
parent | d9d9b707185277db9c0be4eaa2ee5dba9df71fd7 (diff) | |
download | cygnal-166b2571ce446b4085d4c2067b0d0d36c608f131.tar.gz cygnal-166b2571ce446b4085d4c2067b0d0d36c608f131.tar.bz2 cygnal-166b2571ce446b4085d4c2067b0d0d36c608f131.zip |
* Makefile.in: Remove some obsolete stuff.
* dcrt0.cc (dll_crt0_1): Call signal_fixup_after_exec where appropriate. Set
myself->uid from parent version. Just use ThreadItem Init method. Close or
store hexec_proc as appropriate.
(_dll_crt0): Store user_data->forkee here so that proper tests can be made
subsequently.
(do_exit): Remove hExeced stuff.
* environ.cc (environ_init): Accept environ count as well as environ pointer.
* environ.h: Reflect above change.
* pinfo.cc (pinfo_init): Ditto. Accept environ count.
(fixup_in_spawned_child): Remove.
* spawn.cc (spawn_guts): Move signal code to dll_crt0_1. Don't suspend execing
process since it is no longer necessary. Store envc.
* exceptions.cc (signal_fixup_after_exec): New function.
(call_handler): Remove hExeced test.
* child_info.h (cygheap_exec_info): Store envc as well as envp.
(child_info_spawn): Store hexec_proc so that it can be closed in child.
* path.cc (normalize_posix_path): Avoid intermediate use of temporary cwd buf.
(normalize_win32_path): Ditto.
(cwdstuff::get_initial): Always set lock.
* sigproc.h: Remove hExeced.
* strace.cc (strace::vsprntf): Modify to accomodate for lack of hExeced.
* thread.cc (MTinterface::Init): Merge Init1 and ClearReent into this method.
(MTinterface::Init1): Eliminate.
(MTinterface::ClearReent): Eliminate.
* thread.h: Reflect above changes.
* include/sys/strace.h (strace): Make microseconds() public. Make various
functions 'regparm', throughout.
* pinfo.h (_pinfo): Inline simple signal manipulation functions. Requires
inclusion of thread.h which was removed from .cc files, where appropriate.
throughout.
* pinfo.cc: Eliminate signal manipulation functions.
(_pinfo::exit): Calculate total rusage for exiting process here.
* cygheap.cc (size2bucket): Eliminate.
(init_buckets): Ditto.
(_cmalloc): Calculate size and bits in a loop rather than going through a
function call.
(_crealloc): Use stored array index to calculate allocated size.
* spawn.cc (spawn_guts): Use _pinfo exit method to exit, calculating cpu usage.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r-- | winsup/cygwin/pinfo.cc | 112 |
1 files changed, 14 insertions, 98 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 8d037e3af..21aa0fb8d 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -16,7 +16,6 @@ details. */ #include "fhandler.h" #include "dtable.h" #include "cygerrno.h" -#include "thread.h" #include "sync.h" #include "sigproc.h" #include "pinfo.h" @@ -30,7 +29,7 @@ static char NO_COPY pinfo_dummy[sizeof(pinfo)] = {0}; pinfo NO_COPY myself ((_pinfo *)&pinfo_dummy); // Avoid myself != NULL checks -static HANDLE hexec_proc = NULL; +HANDLE hexec_proc = NULL; void __stdcall pinfo_fixup_after_fork () @@ -46,19 +45,6 @@ pinfo_fixup_after_fork () } } -void __stdcall -pinfo_fixup_in_spawned_child (HANDLE hchild) -{ - HANDLE h; - if (!hexec_proc) - return; - if (!DuplicateHandle (hchild, hexec_proc, hMainProc, &h, 0, TRUE, - DUPLICATE_CLOSE_SOURCE)) - system_printf ("couldn't close handle %p in child, %E", hexec_proc); - else - CloseHandle (h); -} - /* Initialize the process table. This is done once when the dll is first loaded. */ @@ -102,11 +88,11 @@ set_myself (pid_t pid, HANDLE h) /* Initialize the process table entry for the current task. This is not called for fork'd tasks, only exec'd ones. */ void __stdcall -pinfo_init (char **envp) +pinfo_init (char **envp, int envc) { if (envp) { - environ_init (envp); + environ_init (envp, envc); /* spawn has already set up a pid structure for us so we'll use that */ myself->process_state |= PID_CYGPARENT; } @@ -120,96 +106,26 @@ pinfo_init (char **envp) myself->ctty = -1; myself->uid = USHRT_MAX; - environ_init (NULL); /* call after myself has been set up */ + environ_init (NULL, 0); /* call after myself has been set up */ } debug_printf ("pid %d, pgid %d", myself->pid, myself->pgid); } void -_pinfo::exit (UINT n) +_pinfo::exit (UINT n, bool norecord) { - process_state = PID_EXITED; - sigproc_printf ("Calling ExitProcess %d", n); - ExitProcess (n); -} + if (!norecord) + process_state = PID_EXITED; -struct sigaction& -_pinfo::getsig(int sig) -{ -#ifdef _MT_SAFE - if (thread2signal) - return thread2signal->sigs[sig]; - return sigs[sig]; -#else - return sigs[sig]; -#endif -}; - -sigset_t& -_pinfo::getsigmask () -{ -#ifdef _MT_SAFE - if (thread2signal) - return *thread2signal->sigmask; - return sig_mask; -#else - return sig_mask; -#endif -}; - -void -_pinfo::setsigmask (sigset_t _mask) -{ -#ifdef _MT_SAFE - if (thread2signal) - *(thread2signal->sigmask) = _mask; - sig_mask=_mask; -#else - sig_mask=_mask; -#endif -} + /* FIXME: There is a potential race between an execed process and its + parent here. I hated to add a mutex just for this, though. */ + struct rusage r; + fill_rusage (&r, hMainProc); + add_rusage (&rusage_self, &r); -LONG * -_pinfo::getsigtodo(int sig) -{ -#ifdef _MT_SAFE - if (thread2signal) - return thread2signal->sigtodo + __SIGOFFSET + sig; - return _sigtodo + __SIGOFFSET + sig; -#else - return _sigtodo + __SIGOFFSET + sig; -#endif -} - -extern HANDLE hMainThread; - -HANDLE -_pinfo::getthread2signal() -{ -#ifdef _MT_SAFE - if (thread2signal) - return thread2signal->win32_obj_id; - return hMainThread; -#else - return hMainThread; -#endif -} - -void -_pinfo::setthread2signal(void *_thr) -{ -#ifdef _MT_SAFE - // assert has myself lock - thread2signal=(ThreadItem*)_thr; -#else -#endif -} - -void -_pinfo::copysigs(_pinfo *_other) -{ - sigs = _other->sigs; + sigproc_printf ("Calling ExitProcess %d", n); + ExitProcess (n); } void |