2014-02-27 22:04:39 -05:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2006,
|
2017-03-06 23:06:12 -08:00
|
|
|
|
* 2007, 2008, 2009, 2011, 2013, 2014, 2017 Free Software Foundation, Inc.
|
2000-06-10 13:24:28 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
|
|
* as published by the Free Software Foundation; either version 3 of
|
|
|
|
|
|
* the License, or (at your option) any later version.
|
2000-06-10 13:24:28 +00:00
|
|
|
|
*
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2000-06-10 13:24:28 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-06-17 00:22:09 +01:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
|
* 02110-1301 USA
|
2003-04-05 19:15:35 +00:00
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2008-09-13 15:35:27 +02:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-03-25 23:59:37 +00:00
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2007-01-15 23:42:45 +00:00
|
|
|
|
#include <fcntl.h> /* for mingw */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#include <signal.h>
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#include <stdio.h>
|
* _scm.h: Removed #include <errno.h>.
* error.c, net_db.c, putenv.c, stime.c: Removed declaration of
errno variable (can be a macro on some systems, for example when
using linux libc with threads).
* error.c, filesys.c, gc.c, ioext.c, iselect.c, net_db.c, ports.c,
posix.c, print.c, putenv.c, scmsigs.c, script.c, simpos.c, smob.c,
socket.c, srcprop.c, stime.c, strop.c, unif.c, vports.c: Added
#include <errno.h> in these 20 out of 100 files.
2001-03-10 16:56:09 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
2007-01-15 23:42:45 +00:00
|
|
|
|
#ifdef HAVE_PROCESS_H
|
|
|
|
|
|
#include <process.h> /* for mingw */
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
2001-07-21 21:11:16 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2008-11-30 18:43:41 +01:00
|
|
|
|
#include <full-write.h>
|
|
|
|
|
|
|
2013-03-09 22:25:35 +01:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/async.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
|
|
|
|
|
#include "libguile/vectors.h"
|
|
|
|
|
|
#include "libguile/threads.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/scmsigs.h"
|
|
|
|
|
|
|
2008-11-30 18:43:41 +01:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
/* SIGRETTYPE is the type that signal handlers return. See <signal.h> */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
#ifdef RETSIGTYPE
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
# define SIGRETTYPE RETSIGTYPE
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#else
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
# ifdef STDC_HEADERS
|
|
|
|
|
|
# define SIGRETTYPE void
|
|
|
|
|
|
# else
|
|
|
|
|
|
# define SIGRETTYPE int
|
|
|
|
|
|
# endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
/* take_signal is installed as the C signal handler whenever a Scheme
|
2005-03-02 20:42:01 +00:00
|
|
|
|
handler is set. When a signal arrives, take_signal will write a
|
|
|
|
|
|
byte into the 'signal pipe'. The 'signal delivery thread' will
|
|
|
|
|
|
read this pipe and queue the appropriate asyncs.
|
|
|
|
|
|
|
|
|
|
|
|
When Guile is built without threads, the signal handler will
|
|
|
|
|
|
install the async directly.
|
|
|
|
|
|
*/
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2002-10-04 14:13:26 +00:00
|
|
|
|
/* Scheme vectors with information about a signal. signal_handlers
|
2005-03-02 20:42:01 +00:00
|
|
|
|
contains the handler procedure or #f, signal_handler_asyncs
|
|
|
|
|
|
contains the thunk to be marked as an async when the signal arrives
|
|
|
|
|
|
(or the cell with the thunk in a singlethreaded Guile), and
|
2002-10-27 20:25:17 +00:00
|
|
|
|
signal_handler_threads points to the thread that a signal should be
|
|
|
|
|
|
delivered to.
|
2002-10-04 14:13:26 +00:00
|
|
|
|
*/
|
2016-11-01 23:31:11 +01:00
|
|
|
|
static scm_i_pthread_mutex_t signal_handler_lock =
|
|
|
|
|
|
SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
static SCM *signal_handlers;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static SCM signal_handler_asyncs;
|
2002-10-04 14:13:26 +00:00
|
|
|
|
static SCM signal_handler_threads;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
/* The signal delivery thread. */
|
|
|
|
|
|
scm_i_thread *scm_i_signal_delivery_thread = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* The mutex held when launching the signal delivery thread. */
|
|
|
|
|
|
static scm_i_pthread_mutex_t signal_delivery_thread_mutex =
|
|
|
|
|
|
SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
/* saves the original C handlers, when a new handler is installed.
|
|
|
|
|
|
set to SIG_ERR if the original handler is installed. */
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
static struct sigaction orig_handlers[NSIG];
|
|
|
|
|
|
#else
|
2000-05-01 22:19:33 +00:00
|
|
|
|
static SIGRETTYPE (*orig_handlers[NSIG])(int);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
close_1 (SCM proc, SCM arg)
|
|
|
|
|
|
{
|
2016-06-24 09:50:23 +02:00
|
|
|
|
/* Eval in the root module so that `lambda' has its usual meaning. */
|
|
|
|
|
|
return scm_eval (scm_list_3 (scm_sym_lambda, SCM_EOL,
|
|
|
|
|
|
scm_list_2 (proc, arg)),
|
|
|
|
|
|
scm_the_root_module ());
|
2005-03-02 20:42:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if SCM_USE_PTHREAD_THREADS
|
2007-01-15 23:42:45 +00:00
|
|
|
|
/* On mingw there's no notion of inter-process signals, only a raise()
|
|
|
|
|
|
within the process itself which apparently invokes the registered handler
|
|
|
|
|
|
immediately. Not sure how well the following code will cope in this
|
|
|
|
|
|
case. It builds but it may not offer quite the same scheme-level
|
|
|
|
|
|
semantics as on a proper system. If you're relying on much in the way of
|
|
|
|
|
|
signal handling on mingw you probably lose anyway. */
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
static int signal_pipe[2];
|
2002-10-27 20:25:17 +00:00
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
static SIGRETTYPE
|
|
|
|
|
|
take_signal (int signum)
|
|
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
char sigbyte = signum;
|
2008-11-30 18:43:41 +01:00
|
|
|
|
full_write (signal_pipe[1], &sigbyte, 1);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
2002-10-04 14:13:26 +00:00
|
|
|
|
#ifndef HAVE_SIGACTION
|
|
|
|
|
|
signal (signum, take_signal);
|
|
|
|
|
|
#endif
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2011-05-26 18:29:05 +02:00
|
|
|
|
struct signal_pipe_data
|
|
|
|
|
|
{
|
|
|
|
|
|
char sigbyte;
|
|
|
|
|
|
ssize_t n;
|
|
|
|
|
|
int err;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void*
|
|
|
|
|
|
read_signal_pipe_data (void * data)
|
|
|
|
|
|
{
|
|
|
|
|
|
struct signal_pipe_data *sdata = data;
|
|
|
|
|
|
|
|
|
|
|
|
sdata->n = read (signal_pipe[0], &sdata->sigbyte, 1);
|
|
|
|
|
|
sdata->err = errno;
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
signal_delivery_thread (void *data)
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
2011-05-26 18:29:05 +02:00
|
|
|
|
int sig;
|
2007-01-15 23:42:45 +00:00
|
|
|
|
#if HAVE_PTHREAD_SIGMASK /* not on mingw, see notes above */
|
|
|
|
|
|
sigset_t all_sigs;
|
2005-03-02 20:42:01 +00:00
|
|
|
|
sigfillset (&all_sigs);
|
2011-06-23 11:23:46 +02:00
|
|
|
|
/* On libgc 7.1 and earlier, GC_do_blocking doesn't actually do
|
|
|
|
|
|
anything. So in that case, libgc will want to suspend the signal
|
|
|
|
|
|
delivery thread, so we need to allow it to do so by unmasking the
|
|
|
|
|
|
suspend signal. */
|
|
|
|
|
|
sigdelset (&all_sigs, GC_get_suspend_signal ());
|
2005-03-02 20:42:01 +00:00
|
|
|
|
scm_i_pthread_sigmask (SIG_SETMASK, &all_sigs, NULL);
|
2007-01-15 23:42:45 +00:00
|
|
|
|
#endif
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
|
{
|
2011-05-26 18:29:05 +02:00
|
|
|
|
struct signal_pipe_data sigdata;
|
|
|
|
|
|
|
|
|
|
|
|
scm_without_guile (read_signal_pipe_data, &sigdata);
|
|
|
|
|
|
|
|
|
|
|
|
sig = sigdata.sigbyte;
|
|
|
|
|
|
if (sigdata.n == 1 && sig >= 0 && sig < NSIG)
|
2005-03-02 20:42:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM h, t;
|
|
|
|
|
|
|
|
|
|
|
|
h = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, sig);
|
|
|
|
|
|
t = SCM_SIMPLE_VECTOR_REF (signal_handler_threads, sig);
|
|
|
|
|
|
if (scm_is_true (h))
|
|
|
|
|
|
scm_system_async_mark_for_thread (h, t);
|
|
|
|
|
|
}
|
2011-05-26 18:29:05 +02:00
|
|
|
|
else if (sigdata.n == 0)
|
2007-10-20 11:09:58 +00:00
|
|
|
|
break; /* the signal pipe was closed. */
|
2011-05-26 18:29:05 +02:00
|
|
|
|
else if (sigdata.n < 0 && sigdata.err != EINTR)
|
2005-03-02 20:42:01 +00:00
|
|
|
|
perror ("error in signal delivery thread");
|
|
|
|
|
|
}
|
2005-05-10 20:04:14 +00:00
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
return SCM_UNSPECIFIED; /* not reached unless all other threads exited */
|
2002-10-04 14:13:26 +00:00
|
|
|
|
}
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static void
|
|
|
|
|
|
start_signal_delivery_thread (void)
|
2002-10-04 14:13:26 +00:00
|
|
|
|
{
|
2007-10-20 11:09:58 +00:00
|
|
|
|
SCM signal_thread;
|
|
|
|
|
|
|
|
|
|
|
|
scm_i_pthread_mutex_lock (&signal_delivery_thread_mutex);
|
|
|
|
|
|
|
2011-06-16 18:27:57 +02:00
|
|
|
|
if (pipe2 (signal_pipe, O_CLOEXEC) != 0)
|
2005-03-02 20:42:01 +00:00
|
|
|
|
scm_syserror (NULL);
|
2007-10-20 11:09:58 +00:00
|
|
|
|
signal_thread = scm_spawn_thread (signal_delivery_thread, NULL,
|
|
|
|
|
|
scm_handle_by_message,
|
|
|
|
|
|
"signal delivery thread");
|
|
|
|
|
|
scm_i_signal_delivery_thread = SCM_I_THREAD_DATA (signal_thread);
|
|
|
|
|
|
|
|
|
|
|
|
scm_i_pthread_mutex_unlock (&signal_delivery_thread_mutex);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_ensure_signal_delivery_thread ()
|
2005-03-02 20:42:01 +00:00
|
|
|
|
{
|
|
|
|
|
|
static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
|
|
|
|
|
|
scm_i_pthread_once (&once, start_signal_delivery_thread);
|
|
|
|
|
|
}
|
2002-10-27 20:25:17 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#else /* !SCM_USE_PTHREAD_THREADS */
|
2002-10-27 20:25:17 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static SIGRETTYPE
|
|
|
|
|
|
take_signal (int signum)
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM cell = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, signum);
|
|
|
|
|
|
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
|
|
|
|
|
|
|
|
|
|
|
if (scm_is_false (SCM_CDR (cell)))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
2016-10-26 22:32:51 +02:00
|
|
|
|
SCM_SETCDR (cell, t->pending_asyncs);
|
|
|
|
|
|
t->pending_asyncs = cell;
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
#ifndef HAVE_SIGACTION
|
|
|
|
|
|
signal (signum, take_signal);
|
|
|
|
|
|
#endif
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_ensure_signal_delivery_thread ()
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2002-10-27 20:25:17 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
#endif /* !SCM_USE_PTHREAD_THREADS */
|
2002-10-27 20:25:17 +00:00
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
static void
|
|
|
|
|
|
install_handler (int signum, SCM thread, SCM handler)
|
|
|
|
|
|
{
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (handler))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (*signal_handlers, signum, SCM_BOOL_F);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (signal_handler_asyncs, signum, SCM_BOOL_F);
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM async = close_1 (handler, scm_from_int (signum));
|
|
|
|
|
|
#if !SCM_USE_PTHREAD_THREADS
|
|
|
|
|
|
async = scm_cons (async, SCM_BOOL_F);
|
|
|
|
|
|
#endif
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (*signal_handlers, signum, handler);
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (signal_handler_asyncs, signum, async);
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (signal_handler_threads, signum, thread);
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2005-03-02 20:42:01 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_sigaction (SCM signum, SCM handler, SCM flags)
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
return scm_sigaction_for_thread (signum, handler, flags, SCM_UNDEFINED);
|
2002-10-27 20:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
/* user interface for installation of signal handlers. */
|
2002-10-04 14:13:26 +00:00
|
|
|
|
SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
|
|
|
|
|
|
(SCM signum, SCM handler, SCM flags, SCM thread),
|
2000-06-05 22:57:51 +00:00
|
|
|
|
"Install or report the signal handler for a specified signal.\n\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"@var{signum} is the signal number, which can be specified using the value\n"
|
|
|
|
|
|
"of variables such as @code{SIGINT}.\n\n"
|
2002-10-04 14:13:26 +00:00
|
|
|
|
"If @var{handler} is omitted, @code{sigaction} returns a pair: the\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"CAR is the current\n"
|
|
|
|
|
|
"signal hander, which will be either an integer with the value @code{SIG_DFL}\n"
|
|
|
|
|
|
"(default action) or @code{SIG_IGN} (ignore), or the Scheme procedure which\n"
|
|
|
|
|
|
"handles the signal, or @code{#f} if a non-Scheme procedure handles the\n"
|
|
|
|
|
|
"signal. The CDR contains the current @code{sigaction} flags for the handler.\n\n"
|
2002-10-04 14:13:26 +00:00
|
|
|
|
"If @var{handler} is provided, it is installed as the new handler for\n"
|
|
|
|
|
|
"@var{signum}. @var{handler} can be a Scheme procedure taking one\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"argument, or the value of @code{SIG_DFL} (default action) or\n"
|
|
|
|
|
|
"@code{SIG_IGN} (ignore), or @code{#f} to restore whatever signal handler\n"
|
2002-10-04 14:13:26 +00:00
|
|
|
|
"was installed before @code{sigaction} was first used. When\n"
|
|
|
|
|
|
"a scheme procedure has been specified, that procedure will run\n"
|
|
|
|
|
|
"in the given @var{thread}. When no thread has been given, the\n"
|
|
|
|
|
|
"thread that made this call to @code{sigaction} is used.\n"
|
Remove AC_SYS_RESTARTABLE_SYSCALLS and related code
As the Autoconf documentation says, "These days portable programs
[...] should not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays
whether a system call is restartable is a dynamic issue, not a
configuration-time issue."
In other words, if we ever rely on HAVE_RESTARTABLE_SYSCALLS, we are
at the mercy of any code that Guile happens to be linked with, because
that code could install a signal handler without the SA_RESTART flag,
and then a Guile system call could unexpectedly return EINTR.
The readline part of this goes back to this problem report:
http://sources.redhat.com/ml/guile/2000-05/msg00177.html; and is an
excellent example of the above paragraph. It was noted during the
discussion that undefining HAVE_RESTARTABLE_SYSCALLS would fix the
problem, but that solution wasn't adopted - I guess because Guile was
still using cooperative threads then (not pthreads) and so there was a
significant concern (whether founded or not) that not using
restartable syscalls (where available) could lead to a loss of
performance.
Now Guile's default mode of operation is with pthreads, where we
already don't assume that HAVE_RESTARTABLE_SYSCALLS is reliable, so
there is no possible further performance loss. And in any case we
really have no choice, if we want correct operation.
Thanks to Sylvain Beucler for reporting this and suggesting the fix.
* configure.in (AC_SYS_RESTARTABLE_SYSCALLS): Removed.
* doc/ref/posix.texi (Signals): Remove statement that Guile always
sets SA_RESTART flag.
* guile-readline/configure.in (GUILE_SIGWINCH_SA_RESTART_CLEARED):
Remove this setting, together with its test code.
(HAVE_RL_PRE_INPUT_HOOK): Remove this setting and its code, as no
longer needed.
* guile-readline/readline.c (sigwinch_enable_restart): Removed.
(scm_init_readline): Remove setting of rl_pre_input_hook.
* libguile/_scm.h (SCM_SYSCALL): Remove the definition that relies on
HAVE_RESTARTABLE_SYSCALLS.
* libguile/scmsigs.c (scm_sigaction_for_thread): Don't always set the
SA_RESTART flag if available. Update docstring accordingly.
(scm_init_scmsigs): Remove code that sets SA_RESTART flag for all
signals.
* THANKS: Add Sylvain.
2009-06-18 20:35:45 +01:00
|
|
|
|
"Flags can optionally be specified for the new handler.\n"
|
|
|
|
|
|
"The return value is a pair with information about the\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"old handler as described above.\n\n"
|
|
|
|
|
|
"This interface does not provide access to the \"signal blocking\"\n"
|
|
|
|
|
|
"facility. Maybe this is not needed, since the thread support may\n"
|
|
|
|
|
|
"provide solutions to the problem of consistent access to data\n"
|
|
|
|
|
|
"structures.")
|
2002-10-04 14:13:26 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sigaction_for_thread
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
int csig;
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
struct sigaction action;
|
|
|
|
|
|
struct sigaction old_action;
|
|
|
|
|
|
#else
|
2002-01-28 21:15:55 +00:00
|
|
|
|
SIGRETTYPE (* chandler) (int) = SIG_DFL;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
SIGRETTYPE (* old_chandler) (int);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
int query_only = 0;
|
|
|
|
|
|
int save_handler = 0;
|
2002-07-20 14:08:34 +00:00
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
SCM old_handler;
|
|
|
|
|
|
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
csig = scm_to_signed_integer (signum, 0, NSIG-1);
|
|
|
|
|
|
|
1999-09-20 21:32:23 +00:00
|
|
|
|
#if defined(HAVE_SIGACTION)
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
action.sa_flags = 0;
|
|
|
|
|
|
if (!SCM_UNBNDP (flags))
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
action.sa_flags |= scm_to_int (flags);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
sigemptyset (&action.sa_mask);
|
2002-10-11 13:02:50 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2002-10-04 14:13:26 +00:00
|
|
|
|
if (SCM_UNBNDP (thread))
|
|
|
|
|
|
thread = scm_current_thread ();
|
|
|
|
|
|
else
|
2017-01-08 12:26:10 +01:00
|
|
|
|
SCM_VALIDATE_THREAD (4, thread);
|
2002-10-11 13:02:50 +00:00
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
scm_i_ensure_signal_delivery_thread ();
|
2005-03-02 20:42:01 +00:00
|
|
|
|
|
2016-11-01 21:40:34 +01:00
|
|
|
|
scm_dynwind_begin (0);
|
2016-12-07 20:01:00 +01:00
|
|
|
|
scm_i_dynwind_pthread_mutex_lock (&signal_handler_lock);
|
2016-11-01 23:31:11 +01:00
|
|
|
|
scm_dynwind_block_asyncs ();
|
2016-11-01 21:40:34 +01:00
|
|
|
|
|
2005-01-02 20:49:04 +00:00
|
|
|
|
old_handler = SCM_SIMPLE_VECTOR_REF (*signal_handlers, csig);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
if (SCM_UNBNDP (handler))
|
|
|
|
|
|
query_only = 1;
|
2004-07-23 15:43:02 +00:00
|
|
|
|
else if (scm_is_integer (handler))
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
long handler_int = scm_to_long (handler);
|
|
|
|
|
|
|
|
|
|
|
|
if (handler_int == (long) SIG_DFL || handler_int == (long) SIG_IGN)
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
2005-03-02 20:42:01 +00:00
|
|
|
|
action.sa_handler = (SIGRETTYPE (*) (int)) handler_int;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#else
|
2005-03-02 20:42:01 +00:00
|
|
|
|
chandler = (SIGRETTYPE (*) (int)) handler_int;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#endif
|
2002-10-27 20:25:17 +00:00
|
|
|
|
install_handler (csig, SCM_BOOL_F, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2009-03-05 20:03:33 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_OUT_OF_RANGE (2, handler);
|
|
|
|
|
|
}
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
2004-07-06 10:59:25 +00:00
|
|
|
|
else if (scm_is_false (handler))
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
/* restore the default handler. */
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
if (orig_handlers[csig].sa_handler == SIG_ERR)
|
|
|
|
|
|
query_only = 1;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
action = orig_handlers[csig];
|
|
|
|
|
|
orig_handlers[csig].sa_handler = SIG_ERR;
|
2002-10-27 20:25:17 +00:00
|
|
|
|
install_handler (csig, SCM_BOOL_F, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (orig_handlers[csig] == SIG_ERR)
|
|
|
|
|
|
query_only = 1;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
chandler = orig_handlers[csig];
|
|
|
|
|
|
orig_handlers[csig] = SIG_ERR;
|
2002-10-27 20:25:17 +00:00
|
|
|
|
install_handler (csig, SCM_BOOL_F, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2000-06-10 13:24:28 +00:00
|
|
|
|
}
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-05-10 22:09:04 +00:00
|
|
|
|
SCM_VALIDATE_PROC (2, handler);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
action.sa_handler = take_signal;
|
|
|
|
|
|
if (orig_handlers[csig].sa_handler == SIG_ERR)
|
|
|
|
|
|
save_handler = 1;
|
|
|
|
|
|
#else
|
|
|
|
|
|
chandler = take_signal;
|
|
|
|
|
|
if (orig_handlers[csig] == SIG_ERR)
|
|
|
|
|
|
save_handler = 1;
|
|
|
|
|
|
#endif
|
2002-10-27 20:25:17 +00:00
|
|
|
|
install_handler (csig, thread, handler);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
2000-06-10 13:24:28 +00:00
|
|
|
|
|
2000-06-05 22:57:51 +00:00
|
|
|
|
/* XXX - Silently ignore setting handlers for `program error signals'
|
|
|
|
|
|
because they can't currently be handled by Scheme code.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
switch (csig)
|
|
|
|
|
|
{
|
|
|
|
|
|
/* This list of program error signals is from the GNU Libc
|
|
|
|
|
|
Reference Manual */
|
|
|
|
|
|
case SIGFPE:
|
|
|
|
|
|
case SIGILL:
|
|
|
|
|
|
case SIGSEGV:
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#ifdef SIGBUS
|
2000-06-05 22:57:51 +00:00
|
|
|
|
case SIGBUS:
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#endif
|
2000-06-05 22:57:51 +00:00
|
|
|
|
case SIGABRT:
|
2000-06-18 12:06:01 +00:00
|
|
|
|
#if defined(SIGIOT) && (SIGIOT != SIGABRT)
|
2000-06-05 22:57:51 +00:00
|
|
|
|
case SIGIOT:
|
|
|
|
|
|
#endif
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#ifdef SIGTRAP
|
2000-06-05 22:57:51 +00:00
|
|
|
|
case SIGTRAP:
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#endif
|
2000-06-05 22:57:51 +00:00
|
|
|
|
#ifdef SIGEMT
|
|
|
|
|
|
case SIGEMT:
|
|
|
|
|
|
#endif
|
2000-06-10 13:24:28 +00:00
|
|
|
|
#ifdef SIGSYS
|
2000-06-05 22:57:51 +00:00
|
|
|
|
case SIGSYS:
|
2000-06-10 13:24:28 +00:00
|
|
|
|
#endif
|
2000-06-05 22:57:51 +00:00
|
|
|
|
query_only = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
if (query_only)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sigaction (csig, 0, &old_action) == -1)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sigaction (csig, &action , &old_action) == -1)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
if (save_handler)
|
|
|
|
|
|
orig_handlers[csig] = old_action;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN)
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
old_handler = scm_from_long ((long) old_action.sa_handler);
|
2016-11-01 21:40:34 +01:00
|
|
|
|
|
|
|
|
|
|
scm_dynwind_end ();
|
|
|
|
|
|
|
2004-07-23 15:43:02 +00:00
|
|
|
|
return scm_cons (old_handler, scm_from_int (old_action.sa_flags));
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#else
|
|
|
|
|
|
if (query_only)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((old_chandler = signal (csig, SIG_IGN)) == SIG_ERR)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
if (signal (csig, old_chandler) == SIG_ERR)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((old_chandler = signal (csig, chandler)) == SIG_ERR)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
if (save_handler)
|
|
|
|
|
|
orig_handlers[csig] = old_chandler;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (old_chandler == SIG_DFL || old_chandler == SIG_IGN)
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
old_handler = scm_from_long ((long) old_chandler);
|
2016-11-01 21:40:34 +01:00
|
|
|
|
|
|
|
|
|
|
scm_dynwind_end ();
|
|
|
|
|
|
|
2004-07-23 15:43:02 +00:00
|
|
|
|
return scm_cons (old_handler, scm_from_int (0));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_restore_signals, "restore-signals", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(void),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return all signal handlers to the values they had before any call to\n"
|
|
|
|
|
|
"@code{sigaction} was made. The return value is unspecified.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_restore_signals
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; i < NSIG; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
if (orig_handlers[i].sa_handler != SIG_ERR)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sigaction (i, &orig_handlers[i], NULL) == -1)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
orig_handlers[i].sa_handler = SIG_ERR;
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (*signal_handlers, i, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (orig_handlers[i] != SIG_ERR)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (signal (i, orig_handlers[i]) == SIG_ERR)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
orig_handlers[i] = SIG_ERR;
|
2005-01-02 20:49:04 +00:00
|
|
|
|
SCM_SIMPLE_VECTOR_SET (*signal_handlers, i, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2014-02-03 23:09:23 -05:00
|
|
|
|
#if HAVE_DECL_ALARM
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM i),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Set a timer to raise a @code{SIGALRM} signal after the specified\n"
|
|
|
|
|
|
"number of seconds (an integer). It's advisable to install a signal\n"
|
|
|
|
|
|
"handler for\n"
|
|
|
|
|
|
"@code{SIGALRM} beforehand, since the default action is to terminate\n"
|
|
|
|
|
|
"the process.\n\n"
|
|
|
|
|
|
"The return value indicates the time remaining for the previous alarm,\n"
|
|
|
|
|
|
"if any. The new value replaces the previous alarm. If there was\n"
|
|
|
|
|
|
"no previous alarm, the return value is zero.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_alarm
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 14:35:36 +00:00
|
|
|
|
return scm_from_uint (alarm (scm_to_uint (i)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
2013-03-09 22:25:35 +01:00
|
|
|
|
#endif /* HAVE_ALARM */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2014-02-28 10:31:12 +01:00
|
|
|
|
static void
|
|
|
|
|
|
pack_tv (struct timeval *tv, SCM seconds, SCM microseconds)
|
|
|
|
|
|
{
|
|
|
|
|
|
tv->tv_sec = scm_to_long (seconds);
|
|
|
|
|
|
tv->tv_usec = scm_to_long (microseconds);
|
|
|
|
|
|
|
|
|
|
|
|
/* Allow usec to be outside the range [0, 999999). */
|
|
|
|
|
|
tv->tv_sec += tv->tv_usec / (1000 * 1000);
|
|
|
|
|
|
tv->tv_usec %= 1000 * 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
unpack_tv (const struct timeval *tv)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_cons (scm_from_long (tv->tv_sec), scm_from_long (tv->tv_usec));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2001-07-19 17:43:22 +00:00
|
|
|
|
#ifdef HAVE_SETITIMER
|
|
|
|
|
|
SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0,
|
|
|
|
|
|
(SCM which_timer,
|
|
|
|
|
|
SCM interval_seconds, SCM interval_microseconds,
|
|
|
|
|
|
SCM value_seconds, SCM value_microseconds),
|
|
|
|
|
|
"Set the timer specified by @var{which_timer} according to the given\n"
|
|
|
|
|
|
"@var{interval_seconds}, @var{interval_microseconds},\n"
|
|
|
|
|
|
"@var{value_seconds}, and @var{value_microseconds} values.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"Return information about the timer's previous setting."
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"Errors are handled as described in the guile info pages under ``POSIX\n"
|
|
|
|
|
|
"Interface Conventions''.\n"
|
|
|
|
|
|
"\n"
|
2001-11-11 15:01:52 +00:00
|
|
|
|
"The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},\n"
|
2001-07-19 17:43:22 +00:00
|
|
|
|
"and @code{ITIMER_PROF}.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"The return value will be a list of two cons pairs representing the\n"
|
|
|
|
|
|
"current state of the given timer. The first pair is the seconds and\n"
|
|
|
|
|
|
"microseconds of the timer @code{it_interval}, and the second pair is\n"
|
2017-03-06 23:06:12 -08:00
|
|
|
|
"the seconds and microseconds of the timer @code{it_value}."
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"@code{ITIMER_PROF} or @code{ITIMER_VIRTUAL} are not supported on\n"
|
|
|
|
|
|
"some platforms and will always error. @code{(provided? 'ITIMER_PROF)}\n"
|
|
|
|
|
|
"and @code{(provided? 'ITIMER_VIRTUAL)} report whether those timers\n"
|
|
|
|
|
|
"are supported.\n")
|
|
|
|
|
|
|
2001-07-19 17:43:22 +00:00
|
|
|
|
#define FUNC_NAME s_scm_setitimer
|
|
|
|
|
|
{
|
|
|
|
|
|
int rv;
|
|
|
|
|
|
int c_which_timer;
|
|
|
|
|
|
struct itimerval new_timer;
|
|
|
|
|
|
struct itimerval old_timer;
|
|
|
|
|
|
|
|
|
|
|
|
c_which_timer = SCM_NUM2INT(1, which_timer);
|
2014-02-28 10:31:12 +01:00
|
|
|
|
pack_tv (&new_timer.it_interval, interval_seconds, interval_microseconds);
|
|
|
|
|
|
pack_tv (&new_timer.it_value, value_seconds, value_microseconds);
|
2001-07-19 17:43:22 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_SYSCALL(rv = setitimer(c_which_timer, &new_timer, &old_timer));
|
|
|
|
|
|
|
|
|
|
|
|
if(rv != 0)
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
|
2014-02-28 10:31:12 +01:00
|
|
|
|
return scm_list_2 (unpack_tv (&old_timer.it_interval),
|
|
|
|
|
|
unpack_tv (&old_timer.it_value));
|
2001-07-19 17:43:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
#endif /* HAVE_SETITIMER */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_GETITIMER
|
|
|
|
|
|
SCM_DEFINE (scm_getitimer, "getitimer", 1, 0, 0,
|
|
|
|
|
|
(SCM which_timer),
|
|
|
|
|
|
"Return information about the timer specified by @var{which_timer}"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"Errors are handled as described in the guile info pages under ``POSIX\n"
|
|
|
|
|
|
"Interface Conventions''.\n"
|
|
|
|
|
|
"\n"
|
2001-11-11 15:01:52 +00:00
|
|
|
|
"The timers available are: @code{ITIMER_REAL}, @code{ITIMER_VIRTUAL},\n"
|
2001-07-19 17:43:22 +00:00
|
|
|
|
"and @code{ITIMER_PROF}.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"The return value will be a list of two cons pairs representing the\n"
|
|
|
|
|
|
"current state of the given timer. The first pair is the seconds and\n"
|
|
|
|
|
|
"microseconds of the timer @code{it_interval}, and the second pair is\n"
|
2017-03-06 23:06:12 -08:00
|
|
|
|
"the seconds and microseconds of the timer @code{it_value}."
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"@code{ITIMER_PROF} or @code{ITIMER_VIRTUAL} are not supported on\n"
|
|
|
|
|
|
"some platforms and will always error. @code{(provided? 'ITIMER_PROF)}\n"
|
|
|
|
|
|
"and @code{(provided? 'ITIMER_VIRTUAL)} report whether those timers\n"
|
|
|
|
|
|
"are supported.\n")
|
2001-07-19 17:43:22 +00:00
|
|
|
|
#define FUNC_NAME s_scm_getitimer
|
|
|
|
|
|
{
|
|
|
|
|
|
int rv;
|
|
|
|
|
|
int c_which_timer;
|
|
|
|
|
|
struct itimerval old_timer;
|
|
|
|
|
|
|
|
|
|
|
|
c_which_timer = SCM_NUM2INT(1, which_timer);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_SYSCALL(rv = getitimer(c_which_timer, &old_timer));
|
2017-03-06 23:06:12 -08:00
|
|
|
|
|
2001-07-19 17:43:22 +00:00
|
|
|
|
if(rv != 0)
|
|
|
|
|
|
SCM_SYSERROR;
|
2017-03-06 23:06:12 -08:00
|
|
|
|
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
return scm_list_2 (scm_cons (scm_from_long (old_timer.it_interval.tv_sec),
|
|
|
|
|
|
scm_from_long (old_timer.it_interval.tv_usec)),
|
|
|
|
|
|
scm_cons (scm_from_long (old_timer.it_value.tv_sec),
|
|
|
|
|
|
scm_from_long (old_timer.it_value.tv_usec)));
|
2001-07-19 17:43:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
#endif /* HAVE_GETITIMER */
|
|
|
|
|
|
|
Changes to compile under gnu-win32, from Marcus Daniels:
* stime.c (tzset): If tzset isn't provided, make it a NOP.
(scm_localtime): Change SCM_EOF to SCM_EOL.
(scm_mktime): Likewise.
* socket.c: Don't include sys/un.h unless autoconf tells
us Unix domain sockets are available.
(scm_fill_sockaddr): Ignore Unix domain code.
(scm_addr_vector): Likewise.
(scm_init_addr_buffer): Likewise.
(scm_socketpair): Don't include unless socketpair was
found during autoconf.
* simpos.c (SYSTNAME): Treat cygwin like Unix.
* scmsigs.c (scm_pause): Don't include unless pause was found
during autoconf.
* posix.c (scm_getgroups): Don't include unless support function
was found during autoconf (in this case, getgroups).
(scm_setpwent): For setpwent.
(scm_setegid): For setegid.
* net_db.c (scm_inet_netof): Don't include unless support
function was found during autoconf (in this case, inet_netof).
(scm_lnaof): For inet_lnaof.
(scm_inet_makeaddr): For inet_makeaddr.
(scm_getnet): For getnetent, getnetbyname, getnetbyaddr.
(scm_getproto): For getprotoent.
(scm_getserv): For getservent.
(scm_sethost): For sethostent, endhostent.
(scm_setnet): For setnetent, endnetent.
(scm_setproto): For setprotoent, endprotoent.
(scm_setserv): For setservent, endservent.
* scmconfig.h.in: Regenerated.
1997-07-11 05:43:36 +00:00
|
|
|
|
#ifdef HAVE_PAUSE
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_pause, "pause", 0, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Pause the current process (thread?) until a signal arrives whose\n"
|
|
|
|
|
|
"action is to either terminate the current process or invoke a\n"
|
|
|
|
|
|
"handler procedure. The return value is unspecified.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_pause
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
pause ();
|
|
|
|
|
|
return SCM_UNSPECIFIED;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
Changes to compile under gnu-win32, from Marcus Daniels:
* stime.c (tzset): If tzset isn't provided, make it a NOP.
(scm_localtime): Change SCM_EOF to SCM_EOL.
(scm_mktime): Likewise.
* socket.c: Don't include sys/un.h unless autoconf tells
us Unix domain sockets are available.
(scm_fill_sockaddr): Ignore Unix domain code.
(scm_addr_vector): Likewise.
(scm_init_addr_buffer): Likewise.
(scm_socketpair): Don't include unless socketpair was
found during autoconf.
* simpos.c (SYSTNAME): Treat cygwin like Unix.
* scmsigs.c (scm_pause): Don't include unless pause was found
during autoconf.
* posix.c (scm_getgroups): Don't include unless support function
was found during autoconf (in this case, getgroups).
(scm_setpwent): For setpwent.
(scm_setegid): For setegid.
* net_db.c (scm_inet_netof): Don't include unless support
function was found during autoconf (in this case, inet_netof).
(scm_lnaof): For inet_lnaof.
(scm_inet_makeaddr): For inet_makeaddr.
(scm_getnet): For getnetent, getnetbyname, getnetbyaddr.
(scm_getproto): For getprotoent.
(scm_getserv): For getservent.
(scm_sethost): For sethostent, endhostent.
(scm_setnet): For setnetent, endnetent.
(scm_setproto): For setprotoent, endprotoent.
(scm_setserv): For setservent, endservent.
* scmconfig.h.in: Regenerated.
1997-07-11 05:43:36 +00:00
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_sleep, "sleep", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM i),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Wait for the given number of seconds (an integer) or until a signal\n"
|
|
|
|
|
|
"arrives. The return value is zero if the time elapses or the number\n"
|
2007-03-07 23:12:36 +00:00
|
|
|
|
"of seconds remaining otherwise.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"See also @code{usleep}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sleep
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
return scm_from_uint (scm_std_sleep (scm_to_uint (i)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_usleep, "usleep", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM i),
|
2007-03-07 23:12:36 +00:00
|
|
|
|
"Wait the given period @var{usecs} microseconds (an integer).\n"
|
|
|
|
|
|
"If a signal arrives the wait stops and the return value is the\n"
|
|
|
|
|
|
"time remaining, in microseconds. If the period elapses with no\n"
|
|
|
|
|
|
"signal the return is zero.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"On most systems the process scheduler is not microsecond accurate and\n"
|
|
|
|
|
|
"the actual period slept by @code{usleep} may be rounded to a system\n"
|
|
|
|
|
|
"clock tick boundary. Traditionally such ticks were 10 milliseconds\n"
|
|
|
|
|
|
"apart, and that interval is often still used.\n"
|
|
|
|
|
|
"\n"
|
|
|
|
|
|
"See also @code{sleep}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_usleep
|
1998-04-20 00:40:09 +00:00
|
|
|
|
{
|
2005-03-02 20:42:01 +00:00
|
|
|
|
return scm_from_ulong (scm_std_usleep (scm_to_ulong (i)));
|
1998-10-13 23:17:34 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-04-20 00:40:09 +00:00
|
|
|
|
|
2000-06-10 13:24:28 +00:00
|
|
|
|
SCM_DEFINE (scm_raise, "raise", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM sig),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Sends a specified signal @var{sig} to the current process, where\n"
|
|
|
|
|
|
"@var{sig} is as described for the kill procedure.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_raise
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2007-01-15 23:42:45 +00:00
|
|
|
|
if (raise (scm_to_int (sig)) != 0)
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_SYSERROR;
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
return SCM_UNSPECIFIED;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-20 11:09:58 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_i_close_signal_pipe()
|
|
|
|
|
|
{
|
|
|
|
|
|
/* SIGNAL_DELIVERY_THREAD_MUTEX is only locked while the signal delivery
|
|
|
|
|
|
thread is being launched. The thread that calls this function is
|
|
|
|
|
|
already holding the thread admin mutex, so if the delivery thread hasn't
|
|
|
|
|
|
been launched at this point, it never will be before shutdown. */
|
|
|
|
|
|
scm_i_pthread_mutex_lock (&signal_delivery_thread_mutex);
|
|
|
|
|
|
|
2008-08-27 23:05:44 +02:00
|
|
|
|
#if SCM_USE_PTHREAD_THREADS
|
2007-10-20 11:09:58 +00:00
|
|
|
|
if (scm_i_signal_delivery_thread != NULL)
|
|
|
|
|
|
close (signal_pipe[1]);
|
2008-08-27 23:05:44 +02:00
|
|
|
|
#endif
|
2007-10-20 11:09:58 +00:00
|
|
|
|
|
|
|
|
|
|
scm_i_pthread_mutex_unlock (&signal_delivery_thread_mutex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
void
|
|
|
|
|
|
scm_init_scmsigs ()
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
signal_handlers =
|
2001-05-15 14:57:22 +00:00
|
|
|
|
SCM_VARIABLE_LOC (scm_c_define ("signal-handlers",
|
|
|
|
|
|
scm_c_make_vector (NSIG, SCM_BOOL_F)));
|
2009-12-05 11:30:09 +01:00
|
|
|
|
signal_handler_asyncs = scm_c_make_vector (NSIG, SCM_BOOL_F);
|
|
|
|
|
|
signal_handler_threads = scm_c_make_vector (NSIG, SCM_BOOL_F);
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < NSIG; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
|
|
orig_handlers[i].sa_handler = SIG_ERR;
|
1999-06-12 17:26:22 +00:00
|
|
|
|
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#else
|
|
|
|
|
|
orig_handlers[i] = SIG_ERR;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
}
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_c_define ("NSIG", scm_from_long (NSIG));
|
|
|
|
|
|
scm_c_define ("SIG_IGN", scm_from_long ((long) SIG_IGN));
|
|
|
|
|
|
scm_c_define ("SIG_DFL", scm_from_long ((long) SIG_DFL));
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#ifdef SA_NOCLDSTOP
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_c_define ("SA_NOCLDSTOP", scm_from_long (SA_NOCLDSTOP));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
* scmsigs.h, async.h: updated.
* _scm.h: if HAVE_RESTARTS is defined then don't use a SYSCALL
loop.
* posix.c (scm_uname): interpret only negative values as an error.
Solaris normally returns a positive value.
* script.c (scm_compile_shell_switches): if we are not going into
an interactive repl, set scm_mask_ints to zero so that asyncs can
run.
* simpos.c (scm_system): don't ignore/unignore signals around
the "system" call.
* posix.c (scm_open_pipe): don't ignore/unignore signals around
the "popen" call.
* init.c (scm_boot_guile_1): don't call scm_init_signals, it's
done in boot-9.scm instead.
* scmsigs.c, async.c: Major rewriting of signal handling code.
(scm_sigaction): new procedure.
(scm_sleep): don't wrap sleep in SCM_SYSCALL, it would mess up the
timing.
(scm_raise): return unspecified, throw error on failure.
* boot-9.scm: signal-handler, alarm-thunk: removed.
don't define ticks-interrupt etc.
top-repl: install signal handlers for SIGINT, SIGFPE, SIGSEGV, SIGBUS
during call to scm-style-repl.
* acconfig.h: mention HAVE_RESTARTS.
* configure.in: check for sigaction and restartable system calls.
1997-05-31 19:02:38 +00:00
|
|
|
|
#ifdef SA_RESTART
|
* numbers.h, numbers.c, discouraged.h, discouraged.c (scm_short2num,
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
2004-08-02 16:14:04 +00:00
|
|
|
|
scm_c_define ("SA_RESTART", scm_from_long (SA_RESTART));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#endif
|
* __scm.h, alist.c, alist.h, append.c, append.h, appinit.c,
arbiters.c, arbiters.h, async.c, async.h, boolean.c, boolean.h,
chars.c, chars.h, continuations.c, continuations.h, debug.c,
debug.h, dynwind.c, dynwind.h, eq.c, eq.h, error.c, eval.c,
eval.h, extchrs.c, extchrs.h, fdsocket.c, fdsocket.h, filesys.c,
filesys.h, fports.c, fports.h, gc.c, gdb_interface.h, gdbint.c,
gdbint.h, genio.c, genio.h, gscm.c, gscm.h, gsubr.c, gsubr.h,
hash.c, hash.h, hashtab.c, hashtab.h, init.c, ioext.c, ioext.h,
kw.c, kw.h, libguile.h, mallocs.c, mallocs.h, markers.c,
markers.h, mbstrings.c, mbstrings.h, numbers.c, numbers.h,
objprop.c, objprop.h, options.c, options.h, pairs.c, pairs.h,
ports.c, ports.h, posix.c, posix.h, print.c, print.h, procprop.c,
procprop.h, procs.c, procs.h, ramap.c, ramap.h, read.c, read.h,
root.c, scmsigs.c, scmsigs.h, sequences.c, sequences.h, simpos.c,
simpos.h, smob.c, socket.c, socket.h, srcprop.c, srcprop.h,
stackchk.c, stackchk.h, stime.c, stime.h, strings.c, strings.h,
strop.c, strop.h, strorder.c, strorder.h, strports.c, strports.h,
struct.c, struct.h, symbols.c, symbols.h, tag.c, tag.h, unif.c,
unif.h, variable.c, variable.h, vectors.c, vectors.h, version.c,
version.h, vports.c, vports.h, weaks.c, weaks.h: Use SCM_P to
declare functions with prototypes. (Patch thanks to Marius
Vollmer.)
1996-10-14 01:33:50 +00:00
|
|
|
|
|
2001-07-19 17:43:22 +00:00
|
|
|
|
#if defined(HAVE_SETITIMER) || defined(HAVE_GETITIMER)
|
|
|
|
|
|
/* Stuff needed by setitimer and getitimer. */
|
2004-07-23 15:43:02 +00:00
|
|
|
|
scm_c_define ("ITIMER_REAL", scm_from_int (ITIMER_REAL));
|
|
|
|
|
|
scm_c_define ("ITIMER_VIRTUAL", scm_from_int (ITIMER_VIRTUAL));
|
|
|
|
|
|
scm_c_define ("ITIMER_PROF", scm_from_int (ITIMER_PROF));
|
2017-03-06 23:06:12 -08:00
|
|
|
|
#ifdef HAVE_USABLE_GETITIMER_PROF
|
|
|
|
|
|
scm_add_feature ("ITIMER_PROF");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef HAVE_USABLE_GETITIMER_VIRTUAL
|
|
|
|
|
|
scm_add_feature ("ITIMER_VIRTUAL");
|
|
|
|
|
|
#endif
|
2001-07-19 17:43:22 +00:00
|
|
|
|
#endif /* defined(HAVE_SETITIMER) || defined(HAVE_GETITIMER) */
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/scmsigs.x"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|