2004-04-05 22:46:29 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004 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
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2000-06-10 13:24:28 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
1996-07-25 22:56:11 +00:00
|
|
|
|
* 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
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2003-03-25 23:59:37 +00:00
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#include <signal.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>
|
|
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/async.h"
|
|
|
|
|
|
#include "libguile/eval.h"
|
2001-06-26 15:46:40 +00:00
|
|
|
|
#include "libguile/root.h"
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/vectors.h"
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/scmsigs.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2001-07-21 21:11:16 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
#define alarm(sec) (0)
|
|
|
|
|
|
/* This weird comma expression is because Sleep is void under Windows. */
|
|
|
|
|
|
#define sleep(sec) (Sleep ((sec) * 1000), 0)
|
2001-11-02 00:16:57 +00:00
|
|
|
|
#define usleep(usec) (Sleep ((usec) / 1000), 0)
|
2001-06-26 17:53:09 +00:00
|
|
|
|
#define kill(pid, sig) raise (sig)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
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
|
2002-10-04 14:13:26 +00:00
|
|
|
|
handler is set. when a signal arrives, take_signal will queue the
|
|
|
|
|
|
Scheme handler procedure for its thread. */
|
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
|
|
|
|
|
|
contains the handler procedure or #f, signal_handler_cells contains
|
2002-10-27 20:25:17 +00:00
|
|
|
|
pre-queued cells for the handler (since we can't do fancy things
|
|
|
|
|
|
during signal delivery), signal_cell_handlers contains the SCM
|
|
|
|
|
|
value to be stuffed into the pre-queued cell upon delivery, and
|
|
|
|
|
|
signal_handler_threads points to the thread that a signal should be
|
|
|
|
|
|
delivered to.
|
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
|
|
|
|
static SCM *signal_handlers;
|
2002-10-04 14:13:26 +00:00
|
|
|
|
static SCM signal_handler_cells;
|
2002-10-27 20:25:17 +00:00
|
|
|
|
static SCM signal_cell_handlers;
|
2002-10-04 14:13:26 +00:00
|
|
|
|
static SCM signal_handler_threads;
|
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
|
|
|
|
/* 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
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
{
|
2002-10-04 14:13:26 +00:00
|
|
|
|
if (signum >= 0 && signum < NSIG)
|
|
|
|
|
|
{
|
2002-10-27 20:25:17 +00:00
|
|
|
|
SCM cell = SCM_VECTOR_REF(signal_handler_cells, signum);
|
|
|
|
|
|
SCM handler = SCM_VECTOR_REF(signal_cell_handlers, signum);
|
|
|
|
|
|
SCM thread = SCM_VECTOR_REF(signal_handler_threads, signum);
|
|
|
|
|
|
scm_root_state *root = scm_i_thread_root (thread);
|
|
|
|
|
|
if (SCM_CONSP (cell))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETCAR (cell, handler);
|
|
|
|
|
|
root->pending_asyncs = 1;
|
|
|
|
|
|
}
|
2002-10-04 14:13:26 +00:00
|
|
|
|
}
|
2002-10-27 20:25:17 +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
|
|
|
|
|
2002-10-04 14:13:26 +00:00
|
|
|
|
SCM
|
|
|
|
|
|
scm_sigaction (SCM signum, SCM handler, SCM 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
|
|
|
|
{
|
2002-10-04 14:13:26 +00:00
|
|
|
|
return scm_sigaction_for_thread (signum, handler, flags, SCM_UNDEFINED);
|
|
|
|
|
|
}
|
* 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
|
|
|
|
|
2002-10-04 14:13:26 +00:00
|
|
|
|
static SCM
|
|
|
|
|
|
close_1 (SCM proc, SCM arg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return scm_primitive_eval_x (scm_list_3 (scm_sym_lambda, SCM_EOL,
|
|
|
|
|
|
scm_list_2 (proc, arg)));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2002-10-27 20:25:17 +00:00
|
|
|
|
/* Make sure that signal SIGNUM can be delivered to THREAD, using
|
|
|
|
|
|
HANDLER. THREAD and HANDLER must either both be non-#f (which
|
|
|
|
|
|
means install the handler), or both #f (which means deinstall an
|
|
|
|
|
|
existing handler).
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
struct install_handler_data {
|
|
|
|
|
|
int signum;
|
|
|
|
|
|
SCM thread;
|
|
|
|
|
|
SCM handler;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static SCM
|
|
|
|
|
|
scm_delq_spine_x (SCM cell, SCM list)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM s = list, prev = SCM_BOOL_F;
|
|
|
|
|
|
|
2004-07-27 15:41:49 +00:00
|
|
|
|
while (!scm_is_eq (cell, s))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (SCM_NULLP (s))
|
|
|
|
|
|
return list;
|
|
|
|
|
|
prev = s;
|
|
|
|
|
|
s = SCM_CDR (s);
|
|
|
|
|
|
}
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (prev))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
return SCM_CDR (cell);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETCDR (prev, SCM_CDR (cell));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
|
|
really_install_handler (void *data)
|
|
|
|
|
|
{
|
|
|
|
|
|
struct install_handler_data *args = data;
|
|
|
|
|
|
int signum = args->signum;
|
|
|
|
|
|
SCM thread = args->thread;
|
|
|
|
|
|
SCM handler = args->handler;
|
|
|
|
|
|
SCM cell;
|
|
|
|
|
|
SCM old_thread;
|
|
|
|
|
|
|
|
|
|
|
|
/* The following modifications are done while signals can be
|
|
|
|
|
|
delivered. That is not a real problem since the signal handler
|
|
|
|
|
|
will only touch the car of the handler cell and set the
|
|
|
|
|
|
pending_asyncs trigger of a thread. While the data structures
|
|
|
|
|
|
are in flux, the signal handler might store the wrong handler in
|
|
|
|
|
|
the cell, or set pending_asyncs of the wrong thread. We fix this
|
|
|
|
|
|
at the end by making sure that the cell has the right handler in
|
|
|
|
|
|
it, if any, and that pending_asyncs is set for the new thread.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Make sure we have a cell. */
|
|
|
|
|
|
cell = SCM_VECTOR_REF (signal_handler_cells, signum);
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (cell))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
cell = scm_cons (SCM_BOOL_F, SCM_EOL);
|
|
|
|
|
|
SCM_VECTOR_SET (signal_handler_cells, signum, cell);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Make sure it is queued for the right thread. */
|
|
|
|
|
|
old_thread = SCM_VECTOR_REF (signal_handler_threads, signum);
|
2004-07-27 15:41:49 +00:00
|
|
|
|
if (!scm_is_eq (thread, old_thread))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
scm_root_state *r;
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (old_thread))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
r = scm_i_thread_root (old_thread);
|
|
|
|
|
|
r->signal_asyncs = scm_delq_spine_x (cell, r->signal_asyncs);
|
|
|
|
|
|
}
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (thread))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
r = scm_i_thread_root (thread);
|
|
|
|
|
|
SCM_SETCDR (cell, r->signal_asyncs);
|
|
|
|
|
|
r->signal_asyncs = cell;
|
|
|
|
|
|
/* Set pending_asyncs just in case. A signal that is
|
|
|
|
|
|
delivered while we modify the data structures here might set
|
|
|
|
|
|
pending_asyncs of old_thread. */
|
|
|
|
|
|
r->pending_asyncs = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_VECTOR_SET (signal_handler_threads, signum, thread);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Set the new handler. */
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_false (handler))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_VECTOR_SET (*signal_handlers, signum, SCM_BOOL_F);
|
|
|
|
|
|
SCM_VECTOR_SET (signal_cell_handlers, signum, SCM_BOOL_F);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_VECTOR_SET (*signal_handlers, signum, handler);
|
|
|
|
|
|
SCM_VECTOR_SET (signal_cell_handlers, signum,
|
|
|
|
|
|
close_1 (handler, scm_int2num (signum)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Now fix up the cell. It might contain the old handler but since
|
|
|
|
|
|
it is now queued for the new thread, we must make sure that the
|
|
|
|
|
|
new handler is run. Any signal that is delivered during the
|
|
|
|
|
|
following code will install the new handler, so we have no
|
|
|
|
|
|
problem.
|
|
|
|
|
|
*/
|
2004-07-06 10:59:25 +00:00
|
|
|
|
if (scm_is_true (SCM_CAR (cell)))
|
2002-10-27 20:25:17 +00:00
|
|
|
|
SCM_SETCAR (cell, SCM_VECTOR_REF (signal_cell_handlers, signum));
|
|
|
|
|
|
|
|
|
|
|
|
/* Phfew. That should be it. */
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
install_handler (int signum, SCM thread, SCM handler)
|
|
|
|
|
|
{
|
|
|
|
|
|
/* We block asyncs while installing the handler. It would be safe
|
|
|
|
|
|
to leave them on, but we might run the wrong handler should a
|
|
|
|
|
|
signal be delivered.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
struct install_handler_data args;
|
|
|
|
|
|
args.signum = signum;
|
|
|
|
|
|
args.thread = thread;
|
|
|
|
|
|
args.handler = handler;
|
|
|
|
|
|
scm_c_call_with_blocked_asyncs (really_install_handler, &args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
* 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"
|
|
|
|
|
|
"Flags can "
|
* 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
|
|
|
|
"optionally be specified for the new handler (@code{SA_RESTART} will\n"
|
2000-06-05 22:57:51 +00:00
|
|
|
|
"always be added if it's available and the system is using restartable\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
|
|
|
|
"system calls.) The return value is a pair with information about the\n"
|
|
|
|
|
|
"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)
|
|
|
|
|
|
#if defined(SA_RESTART) && defined(HAVE_RESTARTABLE_SYSCALLS)
|
|
|
|
|
|
/* don't allow SA_RESTART to be omitted if HAVE_RESTARTABLE_SYSCALLS
|
|
|
|
|
|
is defined, since libguile would be likely to produce spurious
|
|
|
|
|
|
EINTR errors. */
|
* 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 = SA_RESTART;
|
|
|
|
|
|
#else
|
|
|
|
|
|
action.sa_flags = 0;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
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
|
2002-10-27 20:25:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM_VALIDATE_THREAD (4, thread);
|
|
|
|
|
|
if (scm_c_thread_exited_p (thread))
|
|
|
|
|
|
SCM_MISC_ERROR ("thread has already exited", SCM_EOL);
|
|
|
|
|
|
}
|
2002-10-11 13:02:50 +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_DEFER_INTS;
|
2002-10-04 14:13:26 +00:00
|
|
|
|
old_handler = SCM_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
|
|
|
|
{
|
2001-04-10 07:57:05 +00:00
|
|
|
|
if (SCM_NUM2LONG (2, handler) == (long) SIG_DFL
|
|
|
|
|
|
|| SCM_NUM2LONG (2, handler) == (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
|
2004-07-23 15:43:02 +00:00
|
|
|
|
action.sa_handler = (SIGRETTYPE (*) (int)) scm_to_int (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
|
|
|
|
#else
|
2004-07-23 15:43:02 +00:00
|
|
|
|
chandler = (SIGRETTYPE (*) (int)) scm_to_int (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
|
|
|
|
#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
|
1999-12-12 02:36:16 +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)
|
1999-09-20 21:32:23 +00:00
|
|
|
|
old_handler = scm_long2num ((long) old_action.sa_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
|
|
|
|
SCM_ALLOW_INTS;
|
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)
|
2000-05-01 22:19:33 +00:00
|
|
|
|
old_handler = scm_long2num ((long) old_chandler);
|
* 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_ALLOW_INTS;
|
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;
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_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;
|
2002-07-20 14:08:34 +00:00
|
|
|
|
SCM_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
|
|
|
|
|
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
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
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"
|
2001-11-11 15:01:52 +00:00
|
|
|
|
"the seconds and microseconds of the timer @code{it_value}.")
|
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);
|
|
|
|
|
|
new_timer.it_interval.tv_sec = SCM_NUM2LONG(2, interval_seconds);
|
|
|
|
|
|
new_timer.it_interval.tv_usec = SCM_NUM2LONG(3, interval_microseconds);
|
|
|
|
|
|
new_timer.it_value.tv_sec = SCM_NUM2LONG(4, value_seconds);
|
|
|
|
|
|
new_timer.it_value.tv_usec = SCM_NUM2LONG(5, value_microseconds);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_SYSCALL(rv = setitimer(c_which_timer, &new_timer, &old_timer));
|
|
|
|
|
|
|
|
|
|
|
|
if(rv != 0)
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
|
|
|
|
|
|
scm_long2num(old_timer.it_interval.tv_usec)),
|
|
|
|
|
|
scm_cons(scm_long2num(old_timer.it_value.tv_sec),
|
|
|
|
|
|
scm_long2num(old_timer.it_value.tv_usec)));
|
|
|
|
|
|
}
|
|
|
|
|
|
#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"
|
2001-11-11 15:01:52 +00:00
|
|
|
|
"the seconds and microseconds of the timer @code{it_value}.")
|
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));
|
|
|
|
|
|
|
|
|
|
|
|
if(rv != 0)
|
|
|
|
|
|
SCM_SYSERROR;
|
|
|
|
|
|
|
|
|
|
|
|
return scm_list_2(scm_cons(scm_long2num(old_timer.it_interval.tv_sec),
|
|
|
|
|
|
scm_long2num(old_timer.it_interval.tv_usec)),
|
|
|
|
|
|
scm_cons(scm_long2num(old_timer.it_value.tv_sec),
|
|
|
|
|
|
scm_long2num(old_timer.it_value.tv_usec)));
|
|
|
|
|
|
}
|
|
|
|
|
|
#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"
|
|
|
|
|
|
"of seconds remaining otherwise.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sleep
|
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_ulong (scm_thread_sleep (scm_to_int (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),
|
* 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
|
|
|
|
"Sleep for @var{i} microseconds.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_usleep
|
1998-04-20 00:40:09 +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_ulong (scm_thread_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
|
|
|
|
{
|
* 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
|
|
|
|
if (kill (getpid (), 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* 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)));
|
2002-10-04 14:13:26 +00:00
|
|
|
|
signal_handler_cells =
|
|
|
|
|
|
scm_permanent_object (scm_c_make_vector (NSIG, SCM_BOOL_F));
|
2002-10-27 20:25:17 +00:00
|
|
|
|
signal_cell_handlers =
|
|
|
|
|
|
scm_permanent_object (scm_c_make_vector (NSIG, SCM_BOOL_F));
|
2002-10-04 14:13:26 +00:00
|
|
|
|
signal_handler_threads =
|
|
|
|
|
|
scm_permanent_object (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
|
1999-06-12 17:26:22 +00:00
|
|
|
|
|
1999-09-18 17:13:38 +00:00
|
|
|
|
#ifdef HAVE_RESTARTABLE_SYSCALLS
|
1999-09-20 21:32:23 +00:00
|
|
|
|
/* If HAVE_RESTARTABLE_SYSCALLS is defined, it's important that
|
2000-06-10 13:24:28 +00:00
|
|
|
|
signals really are restartable. don't rely on the same
|
1999-09-20 21:32:23 +00:00
|
|
|
|
run-time that configure got: reset the default for every signal.
|
|
|
|
|
|
*/
|
|
|
|
|
|
#ifdef HAVE_SIGINTERRUPT
|
|
|
|
|
|
siginterrupt (i, 0);
|
1999-09-20 22:04:51 +00:00
|
|
|
|
#elif defined(SA_RESTART)
|
1999-06-12 17:26:22 +00:00
|
|
|
|
{
|
|
|
|
|
|
struct sigaction action;
|
|
|
|
|
|
|
|
|
|
|
|
sigaction (i, NULL, &action);
|
|
|
|
|
|
if (!(action.sa_flags & SA_RESTART))
|
|
|
|
|
|
{
|
2000-06-14 00:09:31 +00:00
|
|
|
|
action.sa_flags |= SA_RESTART;
|
1999-06-12 17:26:22 +00:00
|
|
|
|
sigaction (i, &action, NULL);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
1999-09-20 21:32:23 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
/* if neither siginterrupt nor SA_RESTART are available we may
|
|
|
|
|
|
as well assume that signals are always restartable. */
|
1999-06-12 17:26:22 +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
|
|
|
|
|
2001-05-15 14:57:22 +00:00
|
|
|
|
scm_c_define ("NSIG", scm_long2num (NSIG));
|
|
|
|
|
|
scm_c_define ("SIG_IGN", scm_long2num ((long) SIG_IGN));
|
|
|
|
|
|
scm_c_define ("SIG_DFL", scm_long2num ((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
|
2001-05-15 14:57:22 +00:00
|
|
|
|
scm_c_define ("SA_NOCLDSTOP", scm_long2num (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
|
2001-05-15 14:57:22 +00:00
|
|
|
|
scm_c_define ("SA_RESTART", scm_long2num (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));
|
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:
|
|
|
|
|
|
*/
|