diff options
author | Christopher Faylor <me@cgf.cx> | 2005-12-23 22:50:20 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-12-23 22:50:20 +0000 |
commit | dcd0465b2b7d8693d6ba6a4225487b84ef5930a7 (patch) | |
tree | 1b70ddafbdc6d5f8388fbcc0a66089aa0a315cec /winsup/cygwin/pinfo.cc | |
parent | ede284de5fccecbde8a2b0b70471eec4cc5cd3eb (diff) | |
download | newlib-dcd0465b2b7d8693d6ba6a4225487b84ef5930a7.zip newlib-dcd0465b2b7d8693d6ba6a4225487b84ef5930a7.tar.gz newlib-dcd0465b2b7d8693d6ba6a4225487b84ef5930a7.tar.bz2 |
* cygtls.cc (_cygtls::handle_threadlist_exception): Make an error fatal.
* cygtls.h (sockaddr_in): Use header rather than defining our own structure.
* exceptions.cc (_cygtls::interrupt_setup): Use exact contents of sa_mask
rather than assuming tht current sig should be masked, too.
(_cygtls::call_signal_handler): Use more aggressive locking.
* gendef (_sigbe): Wait until later before releasing incyg.
(_sigreturn): Remove more arguments to accommodate quasi-sa_sigaction support.
(_sigdelayed): Push arguments for sa_sigaction. More work needed here.
* signal.cc (sigaction): Implement SA_NODEFER.
* tlsoffsets.h: Regenerate.
* sigproc.cc (wait_sig): Use default buffer size of Windows 9x complains.
* pinfo.cc (_onreturn::dummy_handle): Remove.
(_onreturn::h): Make this a pointer.
(_onreturn::~_onreturn): Detect whether pointer is NULL rather than value is
NULL.
(_onreturn::_onreturn): Set h to NULL initially.
(_onreturn::no_close_p_handle): Set h to NULL.
(winpids::add): Initialize onreturn with value from p.hProcess immediately.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r-- | winsup/cygwin/pinfo.cc | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index cc7cdbf..47c2b7d 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -1091,27 +1091,23 @@ cygwin_winpid_to_pid (int winpid) #define size_pinfolist(i) (sizeof (pinfolist[0]) * ((i) + 1)) class _onreturn { - HANDLE& h; - HANDLE dummy_handle; + HANDLE *h; public: ~_onreturn () { if (h) { - CloseHandle (h); - h = NULL; + CloseHandle (*h); + *h = NULL; } } - void no_close_p_handle () {h = dummy_handle;} - _onreturn (): h (dummy_handle), dummy_handle (NULL) {} - void set (HANDLE& _h) {h = _h;} + void no_close_p_handle () {h = NULL;} + _onreturn (HANDLE& _h): h (&_h) {} }; inline void winpids::add (DWORD& nelem, bool winpid, DWORD pid) { - _onreturn onreturn; - bool perform_copy = make_copy; pid_t cygpid = cygwin_pid (pid); if (nelem >= npidlist) @@ -1126,23 +1122,18 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid) /* Open a the process to prevent a subsequent exit from invalidating the shared memory region. */ p.hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, false, pid); - - p.init (cygpid, PID_NOREDIR | pinfo_access, NULL); + _onreturn onreturn (p.hProcess); /* If we couldn't open the process then we don't have rights to it and should make a copy of the shared memory area if it exists (it may not). - Otherwise, if p is "false" then we couldn't open the shared memory region - for the given pid, so close the handle to that process since we don't need to - protect this pid while the shared memory is open. - If p is true and we've opened the handle then things look good but we want - to track the handle to eventually close it if things fall apart subsequently. */ + bool perform_copy; if (!p.hProcess) perform_copy = true; - else if (!p) - CloseHandle (p.hProcess); else - onreturn.set (p.hProcess); + perform_copy = make_copy; + + p.init (cygpid, PID_NOREDIR | pinfo_access, NULL); /* If we're just looking for winpids then don't do any special cygwin "stuff* */ if (winpid) |