#ifdef I_STDLIB
#include <stdlib.h>
#endif
+#ifndef __ultrix__
#include <string.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <fcntl.h>
#ifdef HAS_TZNAME
-# if !defined(WIN32) && !defined(__CYGWIN__) && !defined(NETWARE) && defined(__UWIN__)
+# if !defined(WIN32) && !defined(__CYGWIN__) && !defined(NETWARE) && !defined(__UWIN__)
extern char *tzname[];
# endif
#else
-#if !defined(WIN32) && !defined(__UWIN__) || (defined(__MINGW32__) && defined(tzname))
+#if !defined(WIN32) && !defined(__UWIN__) || (defined(__MINGW32__) && !defined(tzname))
char *tzname[] = { "" , "" };
#endif
#endif
sigset_t osset;
POSIX__SigSet sigset;
SV** svp;
- SV** sigsvp = hv_fetch(GvHVn(siggv),
- PL_sig_name[sig],
- strlen(PL_sig_name[sig]),
- TRUE);
+ SV** sigsvp;
+ if (sig == 0 && SvPOK(ST(0))) {
+ char *s = SvPVX(ST(0));
+ int i = whichsig(s);
+
+ if (i < 0 && memEQ(s, "SIG", 3))
+ i = whichsig(s + 3);
+ if (i < 0) {
+ if (ckWARN(WARN_SIGNAL))
+ Perl_warner(aTHX_ packWARN(WARN_SIGNAL),
+ "No such signal: SIG%s", s);
+ XSRETURN_UNDEF;
+ }
+ else
+ sig = i;
+ }
+ sigsvp = hv_fetch(GvHVn(siggv),
+ PL_sig_name[sig],
+ strlen(PL_sig_name[sig]),
+ TRUE);
/* Check optaction and set action */
if(SvTRUE(optaction)) {
/* Get back the flags. */
svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
sv_setiv(*svp, oact.sa_flags);
+
+ /* Get back whether the old handler used safe signals. */
+ svp = hv_fetch(oldaction, "SAFE", 4, TRUE);
+ sv_setiv(*svp, oact.sa_handler == PL_csighandlerp);
}
if (action) {
- /* Vector new handler through %SIG. (We always use sighandler
- for the C signal handler, which reads %SIG to dispatch.) */
+ /* Safe signals use "csighandler", which vectors through the
+ PL_sighandlerp pointer when it's safe to do so.
+ (BTW, "csighandler" is very different from "sighandler".) */
+ svp = hv_fetch(action, "SAFE", 4, FALSE);
+ act.sa_handler = (*svp && SvTRUE(*svp))
+ ? PL_csighandlerp : PL_sighandlerp;
+
+ /* Vector new Perl handler through %SIG.
+ (The core signal handlers read %SIG to dispatch.) */
svp = hv_fetch(action, "HANDLER", 7, FALSE);
if (!svp)
croak("Can't supply an action without a HANDLER");
sv_setsv(*sigsvp, *svp);
- mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
+
+ /* This call actually calls sigaction() with almost the
+ right settings, including appropriate interpretation
+ of DEFAULT and IGNORE. However, why are we doing
+ this when we're about to do it again just below? XXX */
+ mg_set(*sigsvp);
+
+ /* And here again we duplicate -- DEFAULT/IGNORE checking. */
if(SvPOK(*svp)) {
char *s=SvPVX(*svp);
if(strEQ(s,"IGNORE")) {
else if(strEQ(s,"DEFAULT")) {
act.sa_handler = SIG_DFL;
}
- else {
- act.sa_handler = PL_sighandlerp;
- }
- }
- else {
- act.sa_handler = PL_sighandlerp;
}
/* Set up any desired mask. */
OUTPUT:
RETVAL
-SV *
+void
nice(incr)
int incr
PPCODE:
char *unparsed;
PPCODE:
num = strtoul(str, &unparsed, base);
- if (num <= IV_MAX)
- PUSHs(sv_2mortal(newSViv((IV)num)));
- else
+#if IVSIZE <= LONGSIZE
+ if (num > IV_MAX)
PUSHs(sv_2mortal(newSVnv((double)num)));
+ else
+#endif
+ PUSHs(sv_2mortal(newSViv((IV)num)));
if (GIMME == G_ARRAY) {
EXTEND(SP, 1);
if (unparsed)