* exceptions.cc (early_stuff_init): Rename from misnamed set_console_handler.
(ctrl_c_handler): Attempt to work around potential signal duplication during process startup. (sig_handle): Ignore SIGINT when we're just an "exec stub". * spawn.cc (spawn_guts): Store pid of spawned process in global for use by ctrl_c_handler. * dcrt0.cc (dll_crt0_1): Call renamed initialization function. * winsup.h: Reflect function name change.
This commit is contained in:
parent
fe37dd79ec
commit
c0a8e8d0f9
|
@ -1,3 +1,16 @@
|
||||||
|
2002-01-09 Christopher Faylor <cgf@redhat.com>
|
||||||
|
Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* exceptions.cc (early_stuff_init): Rename from misnamed
|
||||||
|
set_console_handler.
|
||||||
|
(ctrl_c_handler): Attempt to work around potential signal duplication
|
||||||
|
during process startup.
|
||||||
|
(sig_handle): Ignore SIGINT when we're just an "exec stub".
|
||||||
|
* spawn.cc (spawn_guts): Store pid of spawned process in global for use
|
||||||
|
by ctrl_c_handler.
|
||||||
|
* dcrt0.cc (dll_crt0_1): Call renamed initialization function.
|
||||||
|
* winsup.h: Reflect function name change.
|
||||||
|
|
||||||
2002-01-08 Corinna Vinschen <corinna@vinschen.de>
|
2002-01-08 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* net.cc (cygwin_accept): Set sun_path for newly connected socket.
|
* net.cc (cygwin_accept): Set sun_path for newly connected socket.
|
||||||
|
|
|
@ -813,7 +813,7 @@ _dll_crt0 ()
|
||||||
main_environ = user_data->envptr;
|
main_environ = user_data->envptr;
|
||||||
*main_environ = NULL;
|
*main_environ = NULL;
|
||||||
|
|
||||||
set_console_handler ();
|
early_stuff_init ();
|
||||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentProcess (),
|
||||||
GetCurrentProcess (), &hMainProc, 0, FALSE,
|
GetCurrentProcess (), &hMainProc, 0, FALSE,
|
||||||
DUPLICATE_SAME_ACCESS))
|
DUPLICATE_SAME_ACCESS))
|
||||||
|
|
|
@ -38,6 +38,9 @@ extern DWORD __no_sig_start, __no_sig_end;
|
||||||
|
|
||||||
extern DWORD sigtid;
|
extern DWORD sigtid;
|
||||||
|
|
||||||
|
extern HANDLE hExeced;
|
||||||
|
extern DWORD dwExeced;
|
||||||
|
|
||||||
static BOOL WINAPI ctrl_c_handler (DWORD);
|
static BOOL WINAPI ctrl_c_handler (DWORD);
|
||||||
static void signal_exit (int) __attribute__ ((noreturn));
|
static void signal_exit (int) __attribute__ ((noreturn));
|
||||||
static char windows_system_directory[1024];
|
static char windows_system_directory[1024];
|
||||||
|
@ -113,8 +116,12 @@ init_exception_handler (exception_list *el)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
set_console_handler ()
|
early_stuff_init ()
|
||||||
{
|
{
|
||||||
|
(void) SetConsoleCtrlHandler (ctrl_c_handler, FALSE);
|
||||||
|
if (!SetConsoleCtrlHandler (ctrl_c_handler, TRUE))
|
||||||
|
system_printf ("SetConsoleCtrlHandler failed, %E");
|
||||||
|
|
||||||
/* Initialize global security attribute stuff */
|
/* Initialize global security attribute stuff */
|
||||||
|
|
||||||
sec_none.nLength = sec_none_nih.nLength =
|
sec_none.nLength = sec_none_nih.nLength =
|
||||||
|
@ -124,10 +131,6 @@ set_console_handler ()
|
||||||
sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL;
|
sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL;
|
||||||
sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor =
|
sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor =
|
||||||
get_null_sd ();
|
get_null_sd ();
|
||||||
|
|
||||||
(void) SetConsoleCtrlHandler (ctrl_c_handler, FALSE);
|
|
||||||
if (!SetConsoleCtrlHandler (ctrl_c_handler, TRUE))
|
|
||||||
system_printf ("SetConsoleCtrlHandler failed, %E");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
|
@ -911,8 +914,18 @@ ctrl_c_handler (DWORD type)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we are a stub and the new process has a pinfo structure, let it
|
||||||
|
handle this signal. */
|
||||||
|
if (dwExeced && pinfo (dwExeced))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* We're only the process group leader when we have a valid pinfo structure.
|
||||||
|
If we don't have one, then the parent "stub" will handle the signal. */
|
||||||
|
if (!pinfo (GetCurrentProcessId ()))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
|
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
|
||||||
/* Ignore this if we're not the process group lead since it should be handled
|
/* Ignore this if we're not the process group leader since it should be handled
|
||||||
*by* the process group leader. */
|
*by* the process group leader. */
|
||||||
if (myself->ctty != -1 && t->getpgid () == myself->pid &&
|
if (myself->ctty != -1 && t->getpgid () == myself->pid &&
|
||||||
(GetTickCount () - t->last_ctrl_c) >= MIN_CTRL_C_SLOP)
|
(GetTickCount () - t->last_ctrl_c) >= MIN_CTRL_C_SLOP)
|
||||||
|
@ -925,6 +938,7 @@ ctrl_c_handler (DWORD type)
|
||||||
t->last_ctrl_c = GetTickCount ();
|
t->last_ctrl_c = GetTickCount ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +1011,7 @@ sig_handle (int sig)
|
||||||
if (handler == (void *) SIG_DFL)
|
if (handler == (void *) SIG_DFL)
|
||||||
{
|
{
|
||||||
if (sig == SIGCHLD || sig == SIGIO || sig == SIGCONT || sig == SIGWINCH
|
if (sig == SIGCHLD || sig == SIGIO || sig == SIGCONT || sig == SIGWINCH
|
||||||
|| sig == SIGURG)
|
|| sig == SIGURG || (hExeced && sig == SIGINT))
|
||||||
{
|
{
|
||||||
sigproc_printf ("default signal %d ignored", sig);
|
sigproc_printf ("default signal %d ignored", sig);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1060,8 +1074,6 @@ sig_handle (int sig)
|
||||||
static void
|
static void
|
||||||
signal_exit (int rc)
|
signal_exit (int rc)
|
||||||
{
|
{
|
||||||
extern HANDLE hExeced;
|
|
||||||
|
|
||||||
rc = EXIT_SIGNAL | (rc << 8);
|
rc = EXIT_SIGNAL | (rc << 8);
|
||||||
if (exit_already++)
|
if (exit_already++)
|
||||||
myself->exit (rc);
|
myself->exit (rc);
|
||||||
|
|
|
@ -48,6 +48,7 @@ static suffix_info std_suffixes[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
HANDLE hExeced;
|
HANDLE hExeced;
|
||||||
|
DWORD dwExeced;
|
||||||
|
|
||||||
/* Add .exe to PROG if not already present and see if that exists.
|
/* Add .exe to PROG if not already present and see if that exists.
|
||||||
If not, return PROG (converted from posix to win32 rules if necessary).
|
If not, return PROG (converted from posix to win32 rules if necessary).
|
||||||
|
@ -760,6 +761,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
|
||||||
primarily for strace. */
|
primarily for strace. */
|
||||||
strace.execing = 1;
|
strace.execing = 1;
|
||||||
hExeced = pi.hProcess;
|
hExeced = pi.hProcess;
|
||||||
|
dwExeced = pi.dwProcessId;
|
||||||
strcpy (myself->progname, real_path);
|
strcpy (myself->progname, real_path);
|
||||||
close_all_files ();
|
close_all_files ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag
|
||||||
long __stdcall to_time_t (FILETIME * ptr);
|
long __stdcall to_time_t (FILETIME * ptr);
|
||||||
|
|
||||||
void __stdcall set_console_title (char *);
|
void __stdcall set_console_title (char *);
|
||||||
void set_console_handler ();
|
void early_stuff_init ();
|
||||||
|
|
||||||
int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
|
int __stdcall check_null_str (const char *name) __attribute__ ((regparm(1)));
|
||||||
int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1)));
|
int __stdcall check_null_empty_str (const char *name) __attribute__ ((regparm(1)));
|
||||||
|
|
Loading…
Reference in New Issue