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>2002-10-13 22:16:33 +0400
committerChristopher Faylor <me@cgf.cx>2002-10-13 22:16:33 +0400
commit3f5046a540af860ee6045156becbeb71fa05b220 (patch)
tree20d1e2888b0ea2917df4507f39c1014d64d3789a /winsup/cygwin/dcrt0.cc
parent5cafa3aa1a57a1c1931b8df90ecb0aca91b1eb6d (diff)
* cygthread.cc (cygthread::stub): Don't create event for long-running threads.
Initialize thread_sync event here which is used to Suspend using an event rather than relying on SuspendThread/ResumeThread. (cygthread::init): Save handle to runner thread for future termination. (cygthread::cygthread): Only resume thread when it is actually suspended. Otherwise signal thread completion event. (cygthread::terminate): Forcibly terminate runner thread and any helper threads. Call DisableThreadLibrary calls if execing. * cygthread.h (cygthread::thread_sync): Declare. * dcrt0.cc (do_exit): Eliminate calls to obsolete window_terminate and shared_terminate. * exceptions.cc (events_terminate): Don't bother closing title_mutex since it is going away anyway. * pinfo.cc (_pinfo::exit): Call cygthread::terminate to ensure that threads are shut down before process exit or otherwise strange races seem to occur. * shared.cc (shared_terminate): Eliminate. * shared.h (shared_terminate): Eliminate declaration. * winsup.h (window_terminate): Eliminate declaration. * spawn.cc (spawn_guts): Call cygthread::terminate early in process if execing. Call DisableThreadLibrary calls if execing. * window.cc (Winmain): Call ExitThread to force exit. (window_terminate): Eliminate. * dcrt0.cc (do_exit): Track exit state more closely.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc52
1 files changed, 34 insertions, 18 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index f55b26d22..36442fceb 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -945,19 +945,26 @@ __main (void)
do_global_ctors (user_data->ctors, FALSE);
}
-enum
+enum exit_states
{
- ES_THREADTERM = 1,
- ES_SIGNAL = 2,
- ES_CLOSEALL = 3,
- ES_SIGPROCTERMINATE = 4
+ ES_NOT_EXITING = 0,
+ ES_THREADTERM,
+ ES_SIGNAL,
+ ES_CLOSEALL,
+ ES_SIGPROCTERMINATE,
+ ES_TITLE,
+ ES_HUP_PGRP,
+ ES_HUP_SID,
+ ES_TTY_TERMINATE,
+ ES_EVENTS_TERMINATE
};
+exit_states NO_COPY exit_state;
+
extern "C" void __stdcall
do_exit (int status)
{
UINT n = (UINT) status;
- static int NO_COPY exit_state = 0;
syscall_printf ("do_exit (%d)", n);
@@ -965,10 +972,6 @@ do_exit (int status)
if (vf != NULL && vf->pid < 0)
vf->restore_exit (status);
- if (!DisableThreadLibraryCalls (cygwin_hmodule))
- system_printf ("DisableThreadLibraryCalls (%p) failed, %E",
- cygwin_hmodule);
-
if (exit_state < ES_THREADTERM)
{
exit_state = ES_THREADTERM;
@@ -999,16 +1002,18 @@ do_exit (int status)
sigproc_terminate ();
}
- if (n & EXIT_REPARENTING)
- n &= ~EXIT_REPARENTING;
- else
+ myself->stopsig = 0;
+ if (exit_state < ES_TITLE)
{
- myself->stopsig = 0;
-
+ exit_state = ES_TITLE;
/* restore console title */
if (old_title && display_title)
set_console_title (old_title);
+ }
+ if (exit_state < ES_HUP_PGRP)
+ {
+ exit_state = ES_HUP_PGRP;
/* Kill orphaned children on group leader exit */
if (myself->has_pgid_children && myself->pid == myself->pgid)
{
@@ -1016,7 +1021,11 @@ do_exit (int status)
myself->pid, myself->pgid);
kill_pgrp (myself->pgid, -SIGHUP);
}
+ }
+ if (exit_state < ES_HUP_SID)
+ {
+ exit_state = ES_HUP_SID;
/* Kill the foreground process group on session leader exit */
if (getpgrp () > 0 && myself->pid == myself->sid && real_tty_attached (myself))
{
@@ -1029,12 +1038,19 @@ do_exit (int status)
tp->kill_pgrp (SIGHUP);
}
+ }
+
+ if (exit_state < ES_TTY_TERMINATE)
+ {
+ exit_state = ES_TTY_TERMINATE;
tty_terminate ();
}
- window_terminate ();
- events_terminate ();
- shared_terminate ();
+ if (exit_state < ES_EVENTS_TERMINATE)
+ {
+ exit_state = ES_EVENTS_TERMINATE;
+ events_terminate ();
+ }
minimal_printf ("winpid %d, exit %d", GetCurrentProcessId (), n);
myself->exit (n);