1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

* configure.in: check availability of siginterrupt.

* scmsigs.c (scm_sigaction): add SA_RESTART to flags only if
	HAVE_RESTARTABLE_SYSCALLS.
	(scm_init_scmsigs): use siginterrupt if it's available.  not
	everyone who has restartable syscalls has SA_RESTART it seems.
	(scm_sigaction): use scm_num2long/scm_long2num when converting
	SIG_DFL/SIG_IGN, in case it doesn't fit in an INUM.  use
	scm_integer_p to test the type.
This commit is contained in:
Gary Houston 1999-09-20 21:32:23 +00:00
parent 240ed66f84
commit 7ee92fcefd
6 changed files with 117 additions and 79 deletions

View file

@ -192,9 +192,11 @@ scm_sigaction (SCM signum, SCM handler, SCM flags)
SCM_ASSERT (SCM_INUMP (signum), signum, SCM_ARG1, s_sigaction);
csig = SCM_INUM (signum);
#ifdef HAVE_SIGACTION
/* always use restartable system calls if available. */
#ifdef SA_RESTART
#if defined(HAVE_SIGACTION)
#if defined(SA_RESTART) && defined(HAVE_RESTARTABLE_SYSCALLS)
/* don't allow SA_RESTART to be omitted if HAVE_RESTARTABLE_SYSCALLS
is defined, since libguile would be likely to produce spurious
EINTR errors. */
action.sa_flags = SA_RESTART;
#else
action.sa_flags = 0;
@ -210,12 +212,12 @@ scm_sigaction (SCM signum, SCM handler, SCM flags)
old_handler = scheme_handlers[csig];
if (SCM_UNBNDP (handler))
query_only = 1;
else if (SCM_INUMP (handler))
else if (scm_integer_p (handler) == SCM_BOOL_T)
{
/* It's really ugly to assume that SIG_DFL can be nicely cast to
a fixnum. This has got to go. */
if (SCM_INUM (handler) == (SCM) SIG_DFL
|| SCM_INUM (handler) == (SCM) SIG_IGN)
if (scm_num2long (handler, (char *) SCM_ARG2, s_sigaction)
== (long) SIG_DFL
|| scm_num2long (handler, (char *) SCM_ARG2, s_sigaction)
== (long) SIG_IGN)
{
#ifdef HAVE_SIGACTION
action.sa_handler = (SIGRETTYPE (*) (int)) SCM_INUM (handler);
@ -278,7 +280,7 @@ scm_sigaction (SCM signum, SCM handler, SCM flags)
orig_handlers[csig] = old_action;
}
if (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN)
old_handler = SCM_MAKINUM ((SCM) old_action.sa_handler);
old_handler = scm_long2num ((long) old_action.sa_handler);
SCM_ALLOW_INTS;
return scm_cons (old_handler, SCM_MAKINUM (old_action.sa_flags));
#else
@ -297,7 +299,7 @@ scm_sigaction (SCM signum, SCM handler, SCM flags)
orig_handlers[csig] = old_chandler;
}
if (old_chandler == SIG_DFL || old_chandler == SIG_IGN)
old_handler = SCM_MAKINUM ((int) old_chandler);
old_handler = scm_long2num (old_chandler);
SCM_ALLOW_INTS;
return scm_cons (old_handler, SCM_MAKINUM (0));
#endif
@ -442,9 +444,13 @@ scm_init_scmsigs ()
#endif
#ifdef HAVE_RESTARTABLE_SYSCALLS
/* ensure that system calls will be restarted for all signals. */
/* sigintterupt would be simpler, but it seems better to avoid
dependency on another system call. */
/* If HAVE_RESTARTABLE_SYSCALLS is defined, it's important that
signals really are restartable. don't rely on the same
run-time that configure got: reset the default for every signal.
*/
#ifdef HAVE_SIGINTERRUPT
siginterrupt (i, 0);
#elif defined SA_RESTART
{
struct sigaction action;
@ -455,6 +461,9 @@ scm_init_scmsigs ()
sigaction (i, &action, NULL);
}
}
#endif
/* if neither siginterrupt nor SA_RESTART are available we may
as well assume that signals are always restartable. */
#endif
}