* dtable.h (class dtable): Add class process_lock as a friend.
* dcrt0.cc (get_exit_lock): Delete.
(do_exit): Use process_lock class instead of get_exit_lock.
* exceptions.cc (signal_exit): Ditto.
* pinfo.cc (pinfo::exit): Ditto.
(_pinfo::commune_process): Set process lock around this whole function.
(_pinfo::commune_request): Use process_lock rather than myself.lock.
* pinfo.h (pinfo::_lock): Delete.
(pinfo::initialize_lock): Delete.
(pinfo::lock): Delete.
(pinfo::unlock): Delete.
* winsup.h (get_exit_lock): Delete declaration.
+2005-10-03 Christopher Faylor <cgf@timesys.com>
+
+ * cygheap.h (class process_lock): New class.
+ * dtable.h (class dtable): Add class process_lock as a friend.
+ * dcrt0.cc (get_exit_lock): Delete.
+ (do_exit): Use process_lock class instead of get_exit_lock.
+ * exceptions.cc (signal_exit): Ditto.
+ * pinfo.cc (pinfo::exit): Ditto.
+ (_pinfo::commune_process): Set process lock around this whole function.
+ (_pinfo::commune_request): Use process_lock rather than myself.lock.
+ * pinfo.h (pinfo::_lock): Delete.
+ (pinfo::initialize_lock): Delete.
+ (pinfo::lock): Delete.
+ (pinfo::unlock): Delete.
+ * winsup.h (get_exit_lock): Delete declaration.
+
+
2005-10-03 Corinna Vinschen <corinna@vinschen.de>
* uname.cc (uname): Disable use of GetNativeSystemInfo.
}
};
+class process_lock
+{
+ bool skip_unlock;
+public:
+ process_lock (bool exiting = false)
+ {
+ cygheap->fdtab.lock ();
+ skip_unlock = exiting;
+ if (exiting && exit_state < ES_SET_MUTO)
+ {
+ exit_state = ES_SET_MUTO;
+ muto::set_exiting_thread ();
+ }
+ }
+ ~process_lock ()
+ {
+ if (!skip_unlock)
+ cygheap->fdtab.unlock ();
+ }
+};
+
class child_info;
void __stdcall cygheap_fixup_in_child (bool);
extern "C" {
}
#endif
- get_exit_lock ();
+ process_lock until_exit (true);
if (exit_state < ES_GLOBAL_DTORS)
{
do_exit (((DWORD) n & 0xff) << 8);
}
-void
-get_exit_lock ()
-{
- myself.lock ();
- if (exit_state < ES_SET_MUTO)
- {
- exit_state = ES_SET_MUTO;
- muto::set_exiting_thread ();
- }
-}
-
extern "C" void
__api_fatal (const char *fmt, ...)
{
friend class cygheap_fdget;
friend class cygheap_fdnew;
friend class cygheap_fdenum;
+ friend class process_lock;
};
fhandler_base *build_fh_dev (const device&, const char * = NULL);
#include "shared_info.h"
#include "perprocess.h"
#include "security.h"
+#include "path.h"
+#include "fhandler.h"
+#include "dtable.h"
+#include "cygheap.h"
#define CALL_HANDLER_RETRY 20
TerminateProcess (hExeced, sigExeced = rc);
}
- get_exit_lock ();
+ process_lock until_exit (true);
if (hExeced || exit_state)
myself.exit (rc);
#endif
strace.hello ();
debug_printf ("myself->dwProcessId %u", myself->dwProcessId);
- myself.initialize_lock ();
if (h)
{
/* here if execed */
void
pinfo::exit (DWORD n)
{
- get_exit_lock ();
+ process_lock until_exit ();
cygthread::terminate ();
if (n != EXITCODE_NOSET)
self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */
if (process_sync) // FIXME: this test shouldn't be necessary
ProtectHandle (process_sync);
+ process_lock now (false);
+
switch (si._si_commune._si_code)
{
case PICOM_CMDLINE:
break;
}
- myself.lock ();
+ process_lock now ();
locked = true;
char name_buf[CYG_MAX_PATH];
request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX,
ReleaseSemaphore (request_sync, 1, &res);
ForceCloseHandle (request_sync);
}
- if (locked)
- myself.unlock ();
if (hp)
CloseHandle (hp);
if (fromthem)
public:
HANDLE rd_proc_pipe;
HANDLE hProcess;
- CRITICAL_SECTION _lock;
bool waiter_ready;
class cygthread *wait_thread;
void init (pid_t, DWORD, HANDLE) __attribute__ ((regparm(3)));
}
void exit (DWORD n) __attribute__ ((noreturn, regparm(2)));
void maybe_set_exit_code_from_windows () __attribute__ ((regparm(1)));
- void initialize_lock () {InitializeCriticalSection (&_lock);}
- void lock () {EnterCriticalSection (&_lock);}
- void unlock () {LeaveCriticalSection (&_lock);}
_pinfo *operator -> () const {return procinfo;}
int operator == (pinfo *x) const {return x->procinfo == procinfo;}
int operator == (pinfo &x) const {return x.procinfo == procinfo;}
extern exit_states exit_state;
void __stdcall do_exit (int) __attribute__ ((regparm (1), noreturn));
-void __stdcall get_exit_lock ();
/* UID/GID */
void uinfo_init ();