* 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.
This commit is contained in:
Christopher Faylor
2005-12-23 22:50:20 +00:00
parent ede284de5f
commit dcd0465b2b
12 changed files with 92 additions and 91 deletions

View File

@@ -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)