From: Nick Ing-Simmons Date: Fri, 11 Jan 2002 17:49:39 +0000 (+0000) Subject: A mostly-stable version of "new" Win32 signal/kill support. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1018e26f1c13277648057b08a7b77db44ebc46fe;p=p5sagit%2Fp5-mst-13.2.git A mostly-stable version of "new" Win32 signal/kill support. p4raw-id: //depot/perlio@14192 --- diff --git a/XSUB.h b/XSUB.h index 5066ee2..eef290c 100644 --- a/XSUB.h +++ b/XSUB.h @@ -316,6 +316,8 @@ C. See L. # undef setservent #endif /* NETWARE */ +# undef socketpair + # define mkdir PerlDir_mkdir # define chdir PerlDir_chdir # define rmdir PerlDir_rmdir diff --git a/mg.c b/mg.c index c089c8b..49f8bc4 100644 --- a/mg.c +++ b/mg.c @@ -1073,7 +1073,9 @@ Perl_raise_signal(pTHX_ int sig) Signal_t Perl_csighandler(int sig) { -#ifndef PERL_OLD_SIGNALS +#ifdef PERL_GET_SIG_CONTEXT + dTHXa(PERL_GET_SIG_CONTEXT); +#else dTHX; #endif #ifdef FAKE_PERSISTENT_SIGNAL_HANDLERS @@ -2310,8 +2312,8 @@ static SV* sig_sv; Signal_t Perl_sighandler(int sig) { -#if defined(WIN32) && defined(PERL_IMPLICIT_CONTEXT) - dTHXa(PL_curinterp); /* fake TLS, because signals don't do TLS */ +#ifdef PERL_GET_SIG_CONTEXT + dTHXa(PERL_GET_SIG_CONTEXT); #else dTHX; #endif @@ -2324,10 +2326,6 @@ Perl_sighandler(int sig) U32 flags = 0; XPV *tXpv = PL_Xpv; -#if defined(WIN32) && defined(PERL_IMPLICIT_CONTEXT) - PERL_SET_THX(aTHX); /* fake TLS, see above */ -#endif - if (PL_savestack_ix + 15 <= PL_savestack_max) flags |= 1; if (PL_markstack_ptr < PL_markstack_max - 2) @@ -2481,3 +2479,6 @@ unwind_handler_stack(pTHX_ void *p) SvREFCNT_dec(sig_sv); #endif } + + + diff --git a/win32/config.bc b/win32/config.bc index 01d4e6c..b647858 100644 --- a/win32/config.bc +++ b/win32/config.bc @@ -86,7 +86,7 @@ d_PRIx64='undef' d__fwalk='undef' d_access='define' d_accessx='undef' -d_alarm='undef' +d_alarm='define' d_archlib='define' d_atolf='undef' d_atoll='undef' @@ -728,10 +728,10 @@ shmattype='void *' shortsize='2' shrpenv='' shsharp='true' -sig_name='ZERO NUM01 INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM USR1 USR2 CHLD NUM19 USR3 BREAK ABRT STOP NUM24 CONT CLD' -sig_name_init='"ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "NUM19", "USR3", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' -sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 18 0' -sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 0' +sig_name='ZERO HUP INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM USR1 USR2 CHLD NUM19 USR3 BREAK ABRT STOP NUM24 CONT CLD' +sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "NUM19", "USR3", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' +sig_num='0 1 2 21 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 18 0' +sig_num_init='0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 0' sig_size='27' signal_t='void' sitearch='~INST_TOP~\site~INST_VER~\lib~INST_ARCH~' diff --git a/win32/config.gc b/win32/config.gc index 4cec52c..2587a1a 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -86,7 +86,7 @@ d_PRIx64='undef' d__fwalk='undef' d_access='define' d_accessx='undef' -d_alarm='undef' +d_alarm='define' d_archlib='define' d_atolf='undef' d_atoll='undef' @@ -728,10 +728,10 @@ shmattype='void *' shortsize='2' shrpenv='' shsharp='true' -sig_name='ZERO NUM01 INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD' -sig_name_init='"ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' -sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 0' -sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0' +sig_name='ZERO HUP INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD' +sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' +sig_num='0 1 2 21 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 0' +sig_num_init='0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0' sig_size='27' signal_t='void' sitearch='~INST_TOP~\site~INST_VER~\lib~INST_ARCH~' diff --git a/win32/config.vc b/win32/config.vc index ea064e0..1da4296 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -728,10 +728,10 @@ shmattype='void *' shortsize='2' shrpenv='' shsharp='true' -sig_name='ZERO NUM01 INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD' -sig_name_init='"ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' -sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 0' -sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0' +sig_name='ZERO HUP INT QUIT ILL NUM05 NUM06 NUM07 FPE KILL NUM10 SEGV NUM12 PIPE ALRM TERM NUM16 NUM17 NUM18 NUM19 CHLD BREAK ABRT STOP NUM24 CONT CLD' +sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0' +sig_num='0 1 2 21 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 20 0' +sig_num_init='0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0' sig_size='27' signal_t='void' sitearch='~INST_TOP~\site~INST_VER~\lib~INST_ARCH~' diff --git a/win32/config_H.bc b/win32/config_H.bc index 81261ac..d62882d 100644 --- a/win32/config_H.bc +++ b/win32/config_H.bc @@ -13,7 +13,7 @@ /* * Package name : perl5 * Source directory : - * Configuration time: Sat Dec 29 19:18:51 2001 + * Configuration time: Fri Jan 11 12:16:23 2002 * Configured by : nick * Target system : */ @@ -30,7 +30,7 @@ * This symbol, if defined, indicates that the alarm routine is * available. */ -/*#define HAS_ALARM /**/ +#define HAS_ALARM /**/ /* HASATTRIBUTE: * This symbol indicates the C compiler can check for function attributes, @@ -3082,8 +3082,8 @@ * This variable contains the number of elements of the sig_name * and sig_num arrays, excluding the final NULL entry. */ -#define SIG_NAME "ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "NUM19", "USR3", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ -#define SIG_NUM 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 0 /**/ +#define SIG_NAME "ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "NUM19", "USR3", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ +#define SIG_NUM 0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 18, 0 /**/ #define SIG_SIZE 27 /**/ /* SITEARCH: diff --git a/win32/config_H.gc b/win32/config_H.gc index d2bbc18..ccedfff 100644 --- a/win32/config_H.gc +++ b/win32/config_H.gc @@ -13,7 +13,7 @@ /* * Package name : perl5 * Source directory : - * Configuration time: Sat Dec 29 19:14:21 2001 + * Configuration time: Fri Jan 11 12:16:14 2002 * Configured by : nick * Target system : */ @@ -30,7 +30,7 @@ * This symbol, if defined, indicates that the alarm routine is * available. */ -/*#define HAS_ALARM /**/ +#define HAS_ALARM /**/ /* HASATTRIBUTE: * This symbol indicates the C compiler can check for function attributes, @@ -3082,8 +3082,8 @@ * This variable contains the number of elements of the sig_name * and sig_num arrays, excluding the final NULL entry. */ -#define SIG_NAME "ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ -#define SIG_NUM 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0 /**/ +#define SIG_NAME "ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ +#define SIG_NUM 0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0 /**/ #define SIG_SIZE 27 /**/ /* SITEARCH: diff --git a/win32/config_H.vc b/win32/config_H.vc index e5525c9..2afea67 100644 --- a/win32/config_H.vc +++ b/win32/config_H.vc @@ -13,7 +13,7 @@ /* * Package name : perl5 * Source directory : - * Configuration time: Tue Jan 8 21:51:07 2002 + * Configuration time: Fri Jan 11 12:16:33 2002 * Configured by : nick * Target system : */ @@ -3082,8 +3082,8 @@ * This variable contains the number of elements of the sig_name * and sig_num arrays, excluding the final NULL entry. */ -#define SIG_NAME "ZERO", "NUM01", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ -#define SIG_NUM 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0 /**/ +#define SIG_NAME "ZERO", "HUP", "INT", "QUIT", "ILL", "NUM05", "NUM06", "NUM07", "FPE", "KILL", "NUM10", "SEGV", "NUM12", "PIPE", "ALRM", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "CHLD", "BREAK", "ABRT", "STOP", "NUM24", "CONT", "CLD", 0 /**/ +#define SIG_NUM 0, 1, 2, 21, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 20, 0 /**/ #define SIG_SIZE 27 /**/ /* SITEARCH: diff --git a/win32/config_h.PL b/win32/config_h.PL index 607c484..957966c 100644 --- a/win32/config_h.PL +++ b/win32/config_h.PL @@ -1,5 +1,11 @@ # -use Config; +BEGIN { warn "Running ".__FILE__."\n" }; +BEGIN + { + require "../lib/Config.pm"; + die "../Config.pm:$@" if $@; + Config::->import; + } use File::Compare qw(compare); use File::Copy qw(copy); my $name = $0; @@ -13,6 +19,8 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) $opt{CONFIG_H} ||= 'config.h'; +warn "Writing $opt{CONFIG_H}\n"; + my $patchlevel = $opt{INST_VER}; $patchlevel =~ s|^[\\/]||; $patchlevel =~ s|~VERSION~|$Config{version}|g; diff --git a/win32/makefile.mk b/win32/makefile.mk index b266978..8cafd27 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -897,10 +897,11 @@ regen_config_h: perl config_sh.PL --cfgsh-option-file $(mktmp $(CFG_VARS)) \ $(CFGSH_TMPL) > ..\config.sh -cd .. && del /f perl.exe + -cd .. && del /f perl*.dll cd .. && perl configpm -del /f $(CFGH_TMPL) -mkdir $(COREDIR) - -perl -I..\lib config_h.PL "INST_VER=$(INST_VER)" + -perl config_h.PL "INST_VER=$(INST_VER)" rename config.h $(CFGH_TMPL) $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl diff --git a/win32/win32.c b/win32/win32.c index 9dd9bea..b3e6b8c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4447,19 +4447,24 @@ Perl_init_os_extras(void) */ } -static PerlInterpreter* win32_process_perl = NULL; - -BOOL WINAPI -win32_ctrlhandler(DWORD dwCtrlType) +PerlInterpreter * +win32_signal_context(void) { dTHX; if (!my_perl) { - my_perl = win32_process_perl; - if (!my_perl) { - return FALSE; - } + my_perl = PL_curinterp; PERL_SET_THX(my_perl); - } + } + return my_perl; +} + +BOOL WINAPI +win32_ctrlhandler(DWORD dwCtrlType) +{ + dTHXa(PERL_GET_SIG_CONTEXT); + + if (!my_perl) + return FALSE; switch(dwCtrlType) { case CTRL_CLOSE_EVENT: @@ -4473,12 +4478,12 @@ win32_ctrlhandler(DWORD dwCtrlType) case CTRL_C_EVENT: /* A CTRL+c signal was received */ - CALL_FPTR(PL_sighandlerp)(2); /* SIGINT */ + CALL_FPTR(PL_sighandlerp)(SIGINT); /* SIGINT */ return TRUE; case CTRL_BREAK_EVENT: /* A CTRL+BREAK signal was received */ - CALL_FPTR(PL_sighandlerp)(3); /* SIGQUIT */ + CALL_FPTR(PL_sighandlerp)(SIGBREAK); /* unix calls it SIGQUIT */ return TRUE; case CTRL_LOGOFF_EVENT: @@ -4491,6 +4496,8 @@ win32_ctrlhandler(DWORD dwCtrlType) /* A signal that the system sends to all console processes when the system is shutting down. */ + CALL_FPTR(PL_sighandlerp)(SIGTERM); + return TRUE; break; default: break; @@ -4542,10 +4549,10 @@ Perl_sys_intern_init(pTHX) w32_num_pseudo_children = 0; # endif w32_init_socktype = 0; - if (!win32_process_perl) { - win32_process_perl = my_perl; + if (my_perl == PL_curinterp) { /* Force C runtime signal stuff to set its console handler */ signal(SIGINT,SIG_DFL); + signal(SIGBREAK,SIG_DFL); /* Push our handler on top */ SetConsoleCtrlHandler(win32_ctrlhandler,TRUE); } @@ -4558,9 +4565,8 @@ Perl_sys_intern_clear(pTHX) Safefree(w32_perlshell_vec); /* NOTE: w32_fdpid is freed by sv_clean_all() */ Safefree(w32_children); - if (my_perl == win32_process_perl) { + if (my_perl == PL_curinterp) { SetConsoleCtrlHandler(win32_ctrlhandler,FALSE); - win32_process_perl = NULL; } # ifdef USE_ITHREADS Safefree(w32_pseudo_children); diff --git a/win32/win32.h b/win32/win32.h index a1f7ea0..c20c2f7 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -523,6 +523,9 @@ EXTERN_C _CRTIMP ioinfo* __pioinfo[]; #define EAFNOSUPPORT WSAEAFNOSUPPORT #endif +DllExport PerlInterpreter *win32_signal_context(void); +#define PERL_GET_SIG_CONTEXT win32_signal_context() + #endif /* _INC_WIN32_PERL5 */