diff options
Diffstat (limited to 'REORG.TODO/signal')
49 files changed, 2388 insertions, 0 deletions
diff --git a/REORG.TODO/signal/Makefile b/REORG.TODO/signal/Makefile new file mode 100644 index 0000000000..9ce8232d43 --- /dev/null +++ b/REORG.TODO/signal/Makefile @@ -0,0 +1,57 @@ +# Copyright (C) 1991-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C 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. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# +# Makefile for signal routines. +# +subdir := signal + +include ../Makeconfig + +headers := signal.h sys/signal.h \ + bits/signum.h bits/sigcontext.h bits/sigaction.h \ + bits/sigevent-consts.h bits/siginfo-consts.h \ + bits/sigstack.h bits/sigthread.h bits/ss_flags.h \ + bits/types/__sigset_t.h bits/types/sig_atomic_t.h \ + bits/types/sigevent_t.h bits/types/siginfo_t.h \ + bits/types/sigset_t.h bits/types/sigval_t.h \ + bits/types/stack_t.h bits/types/struct_sigstack.h + +routines := signal raise killpg \ + sigaction sigprocmask kill \ + sigpending sigsuspend sigwait \ + sigblock sigsetmask sigpause sigvec \ + sigstack sigaltstack sigintr \ + sigsetops sigempty sigfillset sigaddset sigdelset sigismem \ + sigreturn \ + siggetmask sysv_signal \ + sigisempty sigandset sigorset \ + allocrtsig sigtimedwait sigwaitinfo sigqueue \ + sighold sigrelse sigignore sigset + +tests := tst-signal tst-sigset tst-sigsimple tst-raise tst-sigset2 + + +include ../Rules + +CFLAGS-sigpause.c = -fexceptions +CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables + +CFLAGS-sigreturn.c = $(no-stack-protector) diff --git a/REORG.TODO/signal/Versions b/REORG.TODO/signal/Versions new file mode 100644 index 0000000000..a915ef400f --- /dev/null +++ b/REORG.TODO/signal/Versions @@ -0,0 +1,54 @@ +libc { + GLIBC_2.0 { + # functions with special/multiple interfaces + __sigpause; __sysv_signal; + + # functions formerly used in inline functions or macros + __sigaddset; __sigdelset; __sigismember; + + # functions used in other libraries + __sigaction; + + # b* + bsd_signal; + + # g* + gsignal; + + # k* + kill; killpg; + + # p* + psignal; + + # r* + raise; + + # s* + sigaction; sigaddset; sigaltstack; sigandset; sigblock; sigdelset; + sigemptyset; sigfillset; siggetmask; siginterrupt; sigisemptyset; + sigismember; siglongjmp; signal; sigorset; sigpause; sigpending; + sigprocmask; sigreturn; sigsetmask; sigstack; sigsuspend; sigvec; + sigwait; ssignal; + } + GLIBC_2.1 { + # helper functions + __libc_current_sigrtmin; __libc_current_sigrtmax; __libc_allocate_rtsig; + + # s* + sighold; sigrelse; sigignore; sigset; sysv_signal; + + # New RT signal functions. + sigqueue; sigtimedwait; sigwaitinfo; + } + GLIBC_2.1.3 { + # LinuxThreads needs this entry point. + __sigsuspend; + } + GLIBC_2.2 { + # Needed to provide a pointer to the XPG sigpause function. + __xpg_sigpause; + } + GLIBC_2.21 { + } +} diff --git a/REORG.TODO/signal/allocrtsig.c b/REORG.TODO/signal/allocrtsig.c new file mode 100644 index 0000000000..d2a4687d68 --- /dev/null +++ b/REORG.TODO/signal/allocrtsig.c @@ -0,0 +1,78 @@ +/* Handle real-time signal allocation. Generic version. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <signal.h> + +/* Another sysdeps file can #define this and then #include this file. */ +#ifndef RESERVED_SIGRT +# define RESERVED_SIGRT 0 +#endif + +/* In these variables we keep track of the used variables. If the + platform does not support any real-time signals we will define the + values to some unreasonable value which will signal failing of all + the functions below. */ +#ifdef __SIGRTMIN +static int current_rtmin = __SIGRTMIN + RESERVED_SIGRT; +static int current_rtmax = __SIGRTMAX; +#endif + +/* Return number of available real-time signal with highest priority. */ +int +__libc_current_sigrtmin (void) +{ +#ifdef __SIGRTMIN + return current_rtmin; +#else + return -1; +#endif +} +libc_hidden_def (__libc_current_sigrtmin) +strong_alias (__libc_current_sigrtmin, __libc_current_sigrtmin_private) + +/* Return number of available real-time signal with lowest priority. */ +int +__libc_current_sigrtmax (void) +{ +#ifdef __SIGRTMIN + return current_rtmax; +#else + return -1; +#endif +} +libc_hidden_def (__libc_current_sigrtmax) +strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private) + +/* Allocate real-time signal with highest/lowest available + priority. Please note that we don't use a lock since we assume + this function to be called at program start. */ +int +__libc_allocate_rtsig (int high) +{ +#ifndef __SIGRTMIN + return -1; +#else + if (current_rtmin == -1 || current_rtmin > current_rtmax) + /* We don't have any more signals available. */ + return -1; + + return high ? current_rtmin++ : current_rtmax--; +#endif +} +strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private) diff --git a/REORG.TODO/signal/bits/types/sig_atomic_t.h b/REORG.TODO/signal/bits/types/sig_atomic_t.h new file mode 100644 index 0000000000..47eaa28311 --- /dev/null +++ b/REORG.TODO/signal/bits/types/sig_atomic_t.h @@ -0,0 +1,10 @@ +#ifndef __sig_atomic_t_defined +#define __sig_atomic_t_defined 1 + +#include <bits/types.h> + +/* An integral type that can be modified atomically, without the + possibility of a signal arriving in the middle of the operation. */ +typedef __sig_atomic_t sig_atomic_t; + +#endif diff --git a/REORG.TODO/signal/bits/types/sigset_t.h b/REORG.TODO/signal/bits/types/sigset_t.h new file mode 100644 index 0000000000..8b27e9112d --- /dev/null +++ b/REORG.TODO/signal/bits/types/sigset_t.h @@ -0,0 +1,9 @@ +#ifndef __sigset_t_defined +#define __sigset_t_defined 1 + +#include <bits/types/__sigset_t.h> + +/* A set of signals to be blocked, unblocked, or waited for. */ +typedef __sigset_t sigset_t; + +#endif diff --git a/REORG.TODO/signal/bits/types/sigval_t.h b/REORG.TODO/signal/bits/types/sigval_t.h new file mode 100644 index 0000000000..666598f0ca --- /dev/null +++ b/REORG.TODO/signal/bits/types/sigval_t.h @@ -0,0 +1,13 @@ +#ifndef __sigval_t_defined +#define __sigval_t_defined + +/* Type for data associated with a signal. */ +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +typedef union sigval sigval_t; + +#endif diff --git a/REORG.TODO/signal/bits/types/struct_sigstack.h b/REORG.TODO/signal/bits/types/struct_sigstack.h new file mode 100644 index 0000000000..5e93ce0091 --- /dev/null +++ b/REORG.TODO/signal/bits/types/struct_sigstack.h @@ -0,0 +1,29 @@ +/* Define struct sigstack. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef __sigstack_defined +#define __sigstack_defined 1 + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + void *ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + +#endif diff --git a/REORG.TODO/signal/kill.c b/REORG.TODO/signal/kill.c new file mode 100644 index 0000000000..c7591b10c1 --- /dev/null +++ b/REORG.TODO/signal/kill.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Send signal SIG to process number PID. If PID is zero, + send SIG to all processes in the current process's process group. + If PID is < -1, send SIG to all processes in process group - PID. */ +int +__kill (int pid, int sig) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (kill) + +weak_alias (__kill, kill) diff --git a/REORG.TODO/signal/killpg.c b/REORG.TODO/signal/killpg.c new file mode 100644 index 0000000000..866f5f6715 --- /dev/null +++ b/REORG.TODO/signal/killpg.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Send SIG to all processes in process group PGRP. + If PGRP is zero, send SIG to all processes in + the current process's process group. */ +int +killpg (__pid_t pgrp, int sig) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (killpg) diff --git a/REORG.TODO/signal/raise.c b/REORG.TODO/signal/raise.c new file mode 100644 index 0000000000..837957aeaf --- /dev/null +++ b/REORG.TODO/signal/raise.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <signal.h> +#include <errno.h> + +/* Raise the signal SIG. */ +int +raise (int sig) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (raise, gsignal) + +stub_warning (raise) +stub_warning (gsignal) diff --git a/REORG.TODO/signal/sigaction.c b/REORG.TODO/signal/sigaction.c new file mode 100644 index 0000000000..8a6220ced3 --- /dev/null +++ b/REORG.TODO/signal/sigaction.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* If ACT is not NULL, change the action for SIG to *ACT. + If OACT is not NULL, put the old action for SIG in *OACT. */ +int +__sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +{ + if (sig <= 0 || sig >= NSIG) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__sigaction) +stub_warning (sigaction) + +weak_alias (__sigaction, sigaction) diff --git a/REORG.TODO/signal/sigaddset.c b/REORG.TODO/signal/sigaddset.c new file mode 100644 index 0000000000..161be7b352 --- /dev/null +++ b/REORG.TODO/signal/sigaddset.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Add SIGNO to SET. */ +int +sigaddset (sigset_t *set, int signo) +{ + if (set == NULL || signo <= 0 || signo >= NSIG) + { + __set_errno (EINVAL); + return -1; + } + + __sigaddset (set, signo); + return 0; +} +libc_hidden_def (sigaddset) diff --git a/REORG.TODO/signal/sigaltstack.c b/REORG.TODO/signal/sigaltstack.c new file mode 100644 index 0000000000..b70afa7127 --- /dev/null +++ b/REORG.TODO/signal/sigaltstack.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1992-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +/* Run signals handlers on the stack specified by SS (if not NULL). + If OSS is not NULL, it is filled in with the old signal stack status. */ +int +sigaltstack (const stack_t *ss, stack_t *oss) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigaltstack) diff --git a/REORG.TODO/signal/sigandset.c b/REORG.TODO/signal/sigandset.c new file mode 100644 index 0000000000..ffea141c63 --- /dev/null +++ b/REORG.TODO/signal/sigandset.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Combine sets LEFT and RIGHT by logical AND and place result in DEST. */ +int +sigandset (sigset_t *dest, const sigset_t *left, const sigset_t *right) +{ + if (!dest || !left || !right) + { + __set_errno (EINVAL); + return -1; + } + + __sigandset (dest, left, right); + return 0; +} diff --git a/REORG.TODO/signal/sigblock.c b/REORG.TODO/signal/sigblock.c new file mode 100644 index 0000000000..a8be9dbde9 --- /dev/null +++ b/REORG.TODO/signal/sigblock.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +/* Block signals in MASK, returning the old mask. */ +int +__sigblock (int mask) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sigblock) + +weak_alias (__sigblock, sigblock) diff --git a/REORG.TODO/signal/sigdelset.c b/REORG.TODO/signal/sigdelset.c new file mode 100644 index 0000000000..2aaa536937 --- /dev/null +++ b/REORG.TODO/signal/sigdelset.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Add SIGNO to SET. */ +int +sigdelset (sigset_t *set, int signo) +{ + if (set == NULL || signo <= 0 || signo >= NSIG) + { + __set_errno (EINVAL); + return -1; + } + + __sigdelset (set, signo); + return 0; +} +libc_hidden_def (sigdelset) diff --git a/REORG.TODO/signal/sigempty.c b/REORG.TODO/signal/sigempty.c new file mode 100644 index 0000000000..1e4b8ca380 --- /dev/null +++ b/REORG.TODO/signal/sigempty.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <string.h> + +/* Clear all signals from SET. */ +int +sigemptyset (sigset_t *set) +{ + if (set == NULL) + { + __set_errno (EINVAL); + return -1; + } + + memset (set, 0, sizeof (sigset_t)); + + return 0; +} +libc_hidden_def (sigemptyset) diff --git a/REORG.TODO/signal/sigfillset.c b/REORG.TODO/signal/sigfillset.c new file mode 100644 index 0000000000..0fcc24a705 --- /dev/null +++ b/REORG.TODO/signal/sigfillset.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <string.h> + +/* Set all signals in SET. */ +int +sigfillset (sigset_t *set) +{ + if (set == NULL) + { + __set_errno (EINVAL); + return -1; + } + + memset (set, 0xff, sizeof (sigset_t)); + + /* If the implementation uses a cancellation signal don't set the bit. */ +#ifdef SIGCANCEL + __sigdelset (set, SIGCANCEL); +#endif + /* Likewise for the signal to implement setxid. */ +#ifdef SIGSETXID + __sigdelset (set, SIGSETXID); +#endif + + return 0; +} +libc_hidden_def (sigfillset) diff --git a/REORG.TODO/signal/siggetmask.c b/REORG.TODO/signal/siggetmask.c new file mode 100644 index 0000000000..6a76df6387 --- /dev/null +++ b/REORG.TODO/signal/siggetmask.c @@ -0,0 +1,28 @@ +/* siggetmask -- useless alias for `sigblock (0)' for old Linux compatibility. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <signal.h> + +int +siggetmask (void) +{ + return __sigblock (0); +} + +link_warning (siggetmask, + "warning: `siggetmask' is obsolete; `sigprocmask' is best") diff --git a/REORG.TODO/signal/sighold.c b/REORG.TODO/signal/sighold.c new file mode 100644 index 0000000000..2e32e4718a --- /dev/null +++ b/REORG.TODO/signal/sighold.c @@ -0,0 +1,39 @@ +/* Add SIG to the calling process' signal mask. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define __need_NULL +#include <stddef.h> +#include <signal.h> + +int +sighold (int sig) +{ + sigset_t set; + + /* Retrieve current signal set. */ + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) + return -1; + + /* Add the specified signal. */ + if (sigaddset (&set, sig) < 0) + return -1; + + /* Set the new mask. */ + return __sigprocmask (SIG_SETMASK, &set, NULL); +} diff --git a/REORG.TODO/signal/sigignore.c b/REORG.TODO/signal/sigignore.c new file mode 100644 index 0000000000..e9e9d054f0 --- /dev/null +++ b/REORG.TODO/signal/sigignore.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the disposition for SIG to SIG_IGN. */ +int +sigignore (int sig) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigignore) diff --git a/REORG.TODO/signal/sigintr.c b/REORG.TODO/signal/sigintr.c new file mode 100644 index 0000000000..39b1100097 --- /dev/null +++ b/REORG.TODO/signal/sigintr.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1992-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +/* If INTERRUPT is nonzero, make signal SIG interrupt system calls + (causing them to fail with EINTR); if INTERRUPT is zero, make system + calls be restarted after signal SIG. */ +int +siginterrupt (int sig, int interrupt) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (siginterrupt) diff --git a/REORG.TODO/signal/sigisempty.c b/REORG.TODO/signal/sigisempty.c new file mode 100644 index 0000000000..bea03f1216 --- /dev/null +++ b/REORG.TODO/signal/sigisempty.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Test whether SET is empty. */ +int +sigisemptyset (const sigset_t *set) +{ + if (!set) + { + __set_errno (EINVAL); + return -1; + } + + return __sigisemptyset (set); +} diff --git a/REORG.TODO/signal/sigismem.c b/REORG.TODO/signal/sigismem.c new file mode 100644 index 0000000000..6ef4a4d19d --- /dev/null +++ b/REORG.TODO/signal/sigismem.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Return 1 if SIGNO is in SET, 0 if not. */ +int +sigismember (const sigset_t *set, int signo) +{ + if (set == NULL || signo <= 0 || signo >= NSIG) + { + __set_errno (EINVAL); + return -1; + } + + return __sigismember (set, signo); +} +libc_hidden_def (sigismember) diff --git a/REORG.TODO/signal/signal.c b/REORG.TODO/signal/signal.c new file mode 100644 index 0000000000..9e541e3030 --- /dev/null +++ b/REORG.TODO/signal/signal.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the handler for the signal SIG to HANDLER, + returning the old handler, or SIG_ERR on error. */ +__sighandler_t +signal (int sig, __sighandler_t handler) +{ + __set_errno (ENOSYS); + return SIG_ERR; +} + +weak_alias (signal, ssignal) + +stub_warning (signal) +stub_warning (ssignal) diff --git a/REORG.TODO/signal/signal.h b/REORG.TODO/signal/signal.h new file mode 100644 index 0000000000..b3114736a5 --- /dev/null +++ b/REORG.TODO/signal/signal.h @@ -0,0 +1,364 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* + * ISO C99 Standard: 7.14 Signal handling <signal.h> + */ + +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include <features.h> + +__BEGIN_DECLS + +#include <bits/types.h> +#include <bits/signum.h> + +#include <bits/types/sig_atomic_t.h> + +#if defined __USE_POSIX +#include <bits/types/sigset_t.h> +#endif + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif +#ifdef __USE_XOPEN +# endif +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif +#endif /* Unix98 */ + +#ifdef __USE_POSIX199309 +/* We need `struct timespec' later on. */ +# include <bits/types/struct_timespec.h> +#endif + +#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED +# include <bits/types/siginfo_t.h> +# include <bits/siginfo-consts.h> +#endif + +#ifdef __USE_POSIX199309 +# include <bits/types/sigevent_t.h> +# include <bits/sigevent-consts.h> +#endif + + +/* Type of a signal handler. */ +typedef void (*__sighandler_t) (int); + +/* The X/Open definition of `signal' specifies the SVID semantic. Use + the additional function `sysv_signal' when X/Open compatibility is + requested. */ +extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#ifdef __USE_GNU +extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Set the handler for the signal SIG to HANDLER, returning the old + handler, or SIG_ERR on error. + By default `signal' has the BSD semantic. */ +#ifdef __USE_MISC +extern __sighandler_t signal (int __sig, __sighandler_t __handler) + __THROW; +#else +/* Make sure the used `signal' implementation is the SVID version. */ +# ifdef __REDIRECT_NTH +extern __sighandler_t __REDIRECT_NTH (signal, + (int __sig, __sighandler_t __handler), + __sysv_signal); +# else +# define signal __sysv_signal +# endif +#endif + +#if defined __USE_XOPEN && !defined __USE_XOPEN2K8 +/* The X/Open definition of `signal' conflicts with the BSD version. + So they defined another function `bsd_signal'. */ +extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Send signal SIG to process number PID. If PID is zero, + send SIG to all processes in the current process's process group. + If PID is < -1, send SIG to all processes in process group - PID. */ +#ifdef __USE_POSIX +extern int kill (__pid_t __pid, int __sig) __THROW; +#endif /* Use POSIX. */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Send SIG to all processes in process group PGRP. + If PGRP is zero, send SIG to all processes in + the current process's process group. */ +extern int killpg (__pid_t __pgrp, int __sig) __THROW; +#endif /* Use misc || X/Open Unix. */ + +/* Raise signal SIG, i.e., send SIG to yourself. */ +extern int raise (int __sig) __THROW; + +#ifdef __USE_MISC +/* SVID names for the same things. */ +extern __sighandler_t ssignal (int __sig, __sighandler_t __handler) + __THROW; +extern int gsignal (int __sig) __THROW; +#endif /* Use misc. */ + +#ifdef __USE_XOPEN2K8 +/* Print a message describing the meaning of the given signal number. */ +extern void psignal (int __sig, const char *__s); + +/* Print a message describing the meaning of the given signal information. */ +extern void psiginfo (const siginfo_t *__pinfo, const char *__s); +#endif /* POSIX 2008. */ + + + +/* The `sigpause' function in X/Open defines the argument as the + signal number. This requires redirecting to another function + because the default version in glibc uses an old BSD interface. + + This function is a cancellation point and therefore not marked with + __THROW. */ + +#ifdef __USE_XOPEN +# ifdef __GNUC__ +extern int sigpause (int __sig) __asm__ ("__xpg_sigpause"); +# else +extern int __sigpause (int __sig_or_mask, int __is_sig); +/* Remove a signal from the signal mask and suspend the process. */ +# define sigpause(sig) __sigpause ((sig), 1) +# endif +#endif + + +#ifdef __USE_MISC +/* None of the following functions should be used anymore. They are here + only for compatibility. A single word (`int') is not guaranteed to be + enough to hold a complete signal mask and therefore these functions + simply do not work in many situations. Use `sigprocmask' instead. */ + +/* Compute mask for signal SIG. */ +# define sigmask(sig) ((int)(1u << ((sig) - 1))) + +/* Block signals in MASK, returning the old mask. */ +extern int sigblock (int __mask) __THROW __attribute_deprecated__; + +/* Set the mask of blocked signals to MASK, returning the old mask. */ +extern int sigsetmask (int __mask) __THROW __attribute_deprecated__; + +/* Return currently selected signal mask. */ +extern int siggetmask (void) __THROW __attribute_deprecated__; +#endif /* Use misc. */ + + +#ifdef __USE_MISC +# define NSIG _NSIG +#endif + +#ifdef __USE_GNU +typedef __sighandler_t sighandler_t; +#endif + +/* 4.4 BSD uses the name `sig_t' for this. */ +#ifdef __USE_MISC +typedef __sighandler_t sig_t; +#endif + +#ifdef __USE_POSIX + +/* Clear all signals from SET. */ +extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Set all signals in SET. */ +extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Add SIGNO to SET. */ +extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Remove SIGNO from SET. */ +extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Return 1 if SIGNO is in SET, 0 if not. */ +extern int sigismember (const sigset_t *__set, int __signo) + __THROW __nonnull ((1)); + +# ifdef __USE_GNU +/* Return non-empty value is SET is not empty. */ +extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1)); + +/* Build new signal set by combining the two inputs set using logical AND. */ +extern int sigandset (sigset_t *__set, const sigset_t *__left, + const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); + +/* Build new signal set by combining the two inputs set using logical OR. */ +extern int sigorset (sigset_t *__set, const sigset_t *__left, + const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); +# endif /* GNU */ + +/* Get the system-specific definitions of `struct sigaction' + and the `SA_*' and `SIG_*'. constants. */ +# include <bits/sigaction.h> + +/* Get and/or change the set of blocked signals. */ +extern int sigprocmask (int __how, const sigset_t *__restrict __set, + sigset_t *__restrict __oset) __THROW; + +/* Change the set of blocked signals to SET, + wait until a signal arrives, and restore the set of blocked signals. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigsuspend (const sigset_t *__set) __nonnull ((1)); + +/* Get and/or set the action for signal SIG. */ +extern int sigaction (int __sig, const struct sigaction *__restrict __act, + struct sigaction *__restrict __oact) __THROW; + +/* Put in SET all signals that are blocked and waiting to be delivered. */ +extern int sigpending (sigset_t *__set) __THROW __nonnull ((1)); + + +/* Select any of pending signals from SET or wait for any to arrive. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig) + __nonnull ((1, 2)); + +# ifdef __USE_POSIX199309 +/* Select any of pending signals from SET and place information in INFO. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwaitinfo (const sigset_t *__restrict __set, + siginfo_t *__restrict __info) __nonnull ((1)); + +/* Select any of pending signals from SET and place information in INFO. + Wait the time specified by TIMEOUT if no signal is pending. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigtimedwait (const sigset_t *__restrict __set, + siginfo_t *__restrict __info, + const struct timespec *__restrict __timeout) + __nonnull ((1)); + +/* Send signal SIG to the process PID. Associate data in VAL with the + signal. */ +extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val) + __THROW; +# endif /* Use POSIX 199306. */ + +#endif /* Use POSIX. */ + +#ifdef __USE_MISC + +/* Names of the signals. This variable exists only for compatibility. + Use `strsignal' instead (see <string.h>). */ +extern const char *const _sys_siglist[_NSIG]; +extern const char *const sys_siglist[_NSIG]; + + +/* Get machine-dependent `struct sigcontext' and signal subcodes. */ +# include <bits/sigcontext.h> + +/* Restore the state saved in SCP. */ +extern int sigreturn (struct sigcontext *__scp) __THROW; + +#endif /* Use misc. */ + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +# define __need_size_t +# include <stddef.h> + +/* If INTERRUPT is nonzero, make signal SIG interrupt system calls + (causing them to fail with EINTR); if INTERRUPT is zero, make system + calls be restarted after signal SIG. */ +extern int siginterrupt (int __sig, int __interrupt) __THROW; + +# include <bits/sigstack.h> +# include <bits/types/stack_t.h> +# include <bits/ss_flags.h> +# if defined __USE_XOPEN || defined __USE_XOPEN2K8 +/* This will define `ucontext_t' and `mcontext_t'. */ +# include <sys/ucontext.h> +# endif + +/* Alternate signal handler stack interface. + This interface should always be preferred over `sigstack'. */ +extern int sigaltstack (const stack_t *__restrict __ss, + stack_t *__restrict __oss) __THROW; + +#endif /* Use POSIX.1-2008 or X/Open Unix. */ + +#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ + || defined __USE_MISC) +# include <bits/types/struct_sigstack.h> +#endif + +#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ + || defined __USE_MISC) +/* Run signals handlers on the stack specified by SS (if not NULL). + If OSS is not NULL, it is filled in with the old signal stack status. + This interface is obsolete and on many platform not implemented. */ +extern int sigstack (struct sigstack *__ss, struct sigstack *__oss) + __THROW __attribute_deprecated__; +#endif + +#ifdef __USE_XOPEN_EXTENDED +/* Simplified interface for signal management. */ + +/* Add SIG to the calling process' signal mask. */ +extern int sighold (int __sig) __THROW; + +/* Remove SIG from the calling process' signal mask. */ +extern int sigrelse (int __sig) __THROW; + +/* Set the disposition of SIG to SIG_IGN. */ +extern int sigignore (int __sig) __THROW; + +/* Set the disposition of SIG. */ +extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW; +#endif + +#if defined __USE_POSIX199506 || defined __USE_UNIX98 +/* Some of the functions for handling signals in threaded programs must + be defined here. */ +# include <bits/pthreadtypes.h> +# include <bits/sigthread.h> +#endif /* use Unix98 */ + +/* The following functions are used internally in the C library and in + other code which need deep insights. */ + +/* Return number of available real-time signal with highest priority. */ +extern int __libc_current_sigrtmin (void) __THROW; +/* Return number of available real-time signal with lowest priority. */ +extern int __libc_current_sigrtmax (void) __THROW; + +__END_DECLS + +#endif /* not signal.h */ diff --git a/REORG.TODO/signal/sigorset.c b/REORG.TODO/signal/sigorset.c new file mode 100644 index 0000000000..8a586db6b5 --- /dev/null +++ b/REORG.TODO/signal/sigorset.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sigsetops.h> + +/* Combine sets LEFT and RIGHT by logical OR and place result in DEST. */ +int +sigorset (sigset_t *dest, const sigset_t *left, const sigset_t *right) +{ + if (!dest || !left || !right) + { + __set_errno (EINVAL); + return -1; + } + + __sigorset (dest, left, right); + return 0; +} diff --git a/REORG.TODO/signal/sigpause.c b/REORG.TODO/signal/sigpause.c new file mode 100644 index 0000000000..b3b155f57e --- /dev/null +++ b/REORG.TODO/signal/sigpause.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define sigpause __rename_sigpause +#include <errno.h> +#include <signal.h> +#undef sigpause + +int +__sigpause (int sig_or_mask, int is_sig) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (__sigpause) +libc_hidden_def (__sigpause) + +int +__attribute__ ((weak)) +__default_sigpause (int mask) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__default_sigpause, sigpause) +stub_warning (sigpause) + + +int +__attribute ((weak)) +__xpg___sigpause (int sig) +{ + __set_errno (ENOSYS); + return -1; +} diff --git a/REORG.TODO/signal/sigpending.c b/REORG.TODO/signal/sigpending.c new file mode 100644 index 0000000000..1814175a2c --- /dev/null +++ b/REORG.TODO/signal/sigpending.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stddef.h> +#include <signal.h> + + +/* Store in SET all signals that are blocked and pending. */ +int +sigpending (sigset_t *set) +{ + if (set == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigpending) diff --git a/REORG.TODO/signal/sigprocmask.c b/REORG.TODO/signal/sigprocmask.c new file mode 100644 index 0000000000..afcf5a116e --- /dev/null +++ b/REORG.TODO/signal/sigprocmask.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* If SET is not NULL, modify the current set of blocked signals + according to HOW, which may be SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK. + If OSET is not NULL, store the old set of blocked signals in *OSET. */ +int +__sigprocmask (int how, const sigset_t *set, sigset_t *oset) +{ + switch (how) + { + case SIG_BLOCK: + case SIG_UNBLOCK: + case SIG_SETMASK: + break; + default: + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +/* No stub warning because abort calls __sigprocmask, + and we don't want warnings for every use of abort on + a system without safe signals. */ + +weak_alias (__sigprocmask, sigprocmask) diff --git a/REORG.TODO/signal/sigqueue.c b/REORG.TODO/signal/sigqueue.c new file mode 100644 index 0000000000..0487acecd7 --- /dev/null +++ b/REORG.TODO/signal/sigqueue.c @@ -0,0 +1,31 @@ +/* Implementation of sigqueue function from POSIX.1b. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <sys/types.h> + +int +__sigqueue (pid_t pid, int sig, const union sigval val) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__sigqueue, sigqueue) + +stub_warning (sigqueue) diff --git a/REORG.TODO/signal/sigrelse.c b/REORG.TODO/signal/sigrelse.c new file mode 100644 index 0000000000..e41c2bd261 --- /dev/null +++ b/REORG.TODO/signal/sigrelse.c @@ -0,0 +1,39 @@ +/* Remove SIG from the calling process' signal mask. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define __need_NULL +#include <stddef.h> +#include <signal.h> + +int +sigrelse (int sig) +{ + sigset_t set; + + /* Retrieve current signal set. */ + if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) + return -1; + + /* Remove the specified signal. */ + if (sigdelset (&set, sig) < 0) + return -1; + + /* Set the new mask. */ + return __sigprocmask (SIG_SETMASK, &set, NULL); +} diff --git a/REORG.TODO/signal/sigreturn.c b/REORG.TODO/signal/sigreturn.c new file mode 100644 index 0000000000..3acad4a81f --- /dev/null +++ b/REORG.TODO/signal/sigreturn.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1992-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <signal.h> +#include <errno.h> + +int +__sigreturn (struct sigcontext *context) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sigreturn) + +weak_alias (__sigreturn, sigreturn) diff --git a/REORG.TODO/signal/sigset.c b/REORG.TODO/signal/sigset.c new file mode 100644 index 0000000000..6ad2cc1fa2 --- /dev/null +++ b/REORG.TODO/signal/sigset.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Set the disposition for SIG. */ +__sighandler_t +sigset (int sig, __sighandler_t disp) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigset) diff --git a/REORG.TODO/signal/sigsetmask.c b/REORG.TODO/signal/sigsetmask.c new file mode 100644 index 0000000000..18321438b7 --- /dev/null +++ b/REORG.TODO/signal/sigsetmask.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +int +__sigsetmask (int mask) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sigsetmask) + +weak_alias (__sigsetmask, sigsetmask) diff --git a/REORG.TODO/signal/sigsetops.c b/REORG.TODO/signal/sigsetops.c new file mode 100644 index 0000000000..d56412f94b --- /dev/null +++ b/REORG.TODO/signal/sigsetops.c @@ -0,0 +1,53 @@ +/* Compatibility symbols for old versions of signal.h. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <signal.h> +#include <sigsetops.h> +#include <shlib-compat.h> + +/* These were formerly defined by <signal.h> as inline functions, + so they require out-of-line compatibility definitions. */ +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_26) + +int +attribute_compat_text_section +(__sigismember) (const __sigset_t *set, int sig) +{ + return __sigismember (set, sig); +} +compat_symbol (libc, __sigismember, __sigismember, GLIBC_2_0); + +int +attribute_compat_text_section +(__sigaddset) (__sigset_t *set, int sig) +{ + __sigaddset (set, sig); + return 0; +} +compat_symbol (libc, __sigaddset, __sigaddset, GLIBC_2_0); + +int +attribute_compat_text_section +(__sigdelset) (__sigset_t *set, int sig) +{ + __sigdelset (set, sig); + return 0; +} +compat_symbol (libc, __sigdelset, __sigdelset, GLIBC_2_0); + +#endif diff --git a/REORG.TODO/signal/sigstack.c b/REORG.TODO/signal/sigstack.c new file mode 100644 index 0000000000..ca5046bff7 --- /dev/null +++ b/REORG.TODO/signal/sigstack.c @@ -0,0 +1,30 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +/* Run signals handlers on the stack specified by SS (if not NULL). + If OSS is not NULL, it is filled in with the old signal stack status. */ +int +sigstack (struct sigstack *ss, struct sigstack *oss) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (sigstack) diff --git a/REORG.TODO/signal/sigsuspend.c b/REORG.TODO/signal/sigsuspend.c new file mode 100644 index 0000000000..f80d7998a1 --- /dev/null +++ b/REORG.TODO/signal/sigsuspend.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + + +/* Change the set of blocked signals to SET, + wait until a signal arrives, and restore the set of blocked signals. */ +int +__sigsuspend (const sigset_t *set) +{ + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__sigsuspend) +weak_alias (__sigsuspend, sigsuspend) + +stub_warning (sigsuspend) +stub_warning (__sigsuspend) diff --git a/REORG.TODO/signal/sigtimedwait.c b/REORG.TODO/signal/sigtimedwait.c new file mode 100644 index 0000000000..3b42003e26 --- /dev/null +++ b/REORG.TODO/signal/sigtimedwait.c @@ -0,0 +1,32 @@ +/* Implementation of sigtimedwait function from POSIX.1b. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +int +__sigtimedwait (const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) +{ + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__sigtimedwait) +weak_alias (__sigtimedwait, sigtimedwait) + +stub_warning (sigtimedwait) diff --git a/REORG.TODO/signal/sigvec.c b/REORG.TODO/signal/sigvec.c new file mode 100644 index 0000000000..5313002089 --- /dev/null +++ b/REORG.TODO/signal/sigvec.c @@ -0,0 +1,202 @@ +/* ABI compatibility for obsolete sigvec function from 4.2BSD. + Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <shlib-compat.h> + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_21) + +# include <signal.h> +# include <errno.h> +# include <stddef.h> + + +/* These are the struct sigvec and SV_* bit definitions that + used to be in <signal.h>. The whole interface now exists + solely for ABI compatibility, so it can just be here. */ +struct sigvec + { + __sighandler_t sv_handler; /* Signal handler. */ + int sv_mask; /* Mask of signals to be blocked. */ + + int sv_flags; /* Flags (see below). */ + }; +# define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */ +# define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */ +# define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */ + + +/* Include macros to convert between `sigset_t' and old-style mask. */ +# include <sigset-cvt-mask.h> + +# ifndef SA_RESETHAND +/* When sigaction lacks the extension bit for it, + we use a wrapper handler to support SV_RESETHAND. */ +struct sigvec_wrapper_data +{ + __sighandler_t sw_handler; + unsigned int sw_mask; +}; + +static void sigvec_wrapper_handler (int sig) __THROW; + +static struct sigvec_wrapper_data sigvec_wrapper_data[NSIG]; +# endif + + +/* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member + of VEC. The signals in `sv_mask' will be blocked while the handler runs. + If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be + reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL, + it is filled in with the old information for SIG. */ +int +__sigvec (int sig, + const struct sigvec *vec, + struct sigvec *ovec) +{ + struct sigaction old; + +# ifndef SA_RESETHAND + if (vec == NULL || !(vec->sv_flags & SV_RESETHAND)) +# endif + { + struct sigaction new, *n; + + if (vec == NULL) + n = NULL; + else + { + __sighandler_t handler; + unsigned int mask; + unsigned int sv_flags; + unsigned int sa_flags; + + handler = vec->sv_handler; + mask = vec->sv_mask; + sv_flags = vec->sv_flags; + sa_flags = 0; + if (sv_flags & SV_ONSTACK) + { +# ifdef SA_ONSTACK + sa_flags |= SA_ONSTACK; +# else + __set_errno (ENOSYS); + return -1; +# endif + } +# ifdef SA_RESTART + if (!(sv_flags & SV_INTERRUPT)) + sa_flags |= SA_RESTART; +# endif +# ifdef SA_RESETHAND + if (sv_flags & SV_RESETHAND) + sa_flags |= SA_RESETHAND; +# endif + n = &new; + new.sa_handler = handler; + if (sigset_set_old_mask (&new.sa_mask, mask) < 0) + return -1; + new.sa_flags = sa_flags; + } + + if (__sigaction (sig, n, &old) < 0) + return -1; + } +# ifndef SA_RESETHAND + else + { + __sighandler_t handler; + unsigned int mask; + struct sigvec_wrapper_data *data; + struct sigaction wrapper; + + handler = vec->sv_handler; + mask = (unsigned int)vec->sv_mask; + data = &sigvec_wrapper_data[sig]; + wrapper.sa_handler = sigvec_wrapper_handler; + /* FIXME: should we set wrapper.sa_mask, wrapper.sa_flags?? */ + data->sw_handler = handler; + data->sw_mask = mask; + + if (__sigaction (sig, &wrapper, &old) < 0) + return -1; + } +# endif + + if (ovec != NULL) + { + __sighandler_t handler; + unsigned int sv_flags; + unsigned int sa_flags; + unsigned int mask; + + handler = old.sa_handler; + sv_flags = 0; + sa_flags = old.sa_flags; +# ifndef SA_RESETHAND + if (handler == sigvec_wrapper_handler) + { + handler = sigvec_wrapper_data[sig].sw_handler; + /* should we use data->sw_mask?? */ + sv_flags |= SV_RESETHAND; + } +# else + if (sa_flags & SA_RESETHAND) + sv_flags |= SV_RESETHAND; +# endif + mask = sigset_get_old_mask (&old.sa_mask); +# ifdef SA_ONSTACK + if (sa_flags & SA_ONSTACK) + sv_flags |= SV_ONSTACK; +# endif +# ifdef SA_RESTART + if (!(sa_flags & SA_RESTART)) +# endif + sv_flags |= SV_INTERRUPT; + ovec->sv_handler = handler; + ovec->sv_mask = (int)mask; + ovec->sv_flags = (int)sv_flags; + } + + return 0; +} + +compat_symbol (libc, __sigvec, sigvec, GLIBC_2_0); + +# ifndef SA_RESETHAND +static void +sigvec_wrapper_handler (int sig) +{ + struct sigvec_wrapper_data *data; + struct sigaction act; + int save; + __sighandler_t handler; + + data = &sigvec_wrapper_data[sig]; + act.sa_handler = SIG_DFL; + act.sa_flags = 0; + sigset_set_old_mask (&act.sa_mask, data->sw_mask); + handler = data->sw_handler; + save = errno; + (void) __sigaction (sig, &act, (struct sigaction *) NULL); + __set_errno (save); + + (*handler) (sig); +} +# endif /* No SA_RESETHAND. */ + +#endif /* SHLIB_COMPAT */ diff --git a/REORG.TODO/signal/sigwait.c b/REORG.TODO/signal/sigwait.c new file mode 100644 index 0000000000..da74c0e3b1 --- /dev/null +++ b/REORG.TODO/signal/sigwait.c @@ -0,0 +1,30 @@ +/* sigwait - implementation of sigwait function from POSIX.1c. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +int +__sigwait (const sigset_t *set, int *sig) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__sigwait, sigwait) + +stub_warning (sigwait) diff --git a/REORG.TODO/signal/sigwaitinfo.c b/REORG.TODO/signal/sigwaitinfo.c new file mode 100644 index 0000000000..2375e06d75 --- /dev/null +++ b/REORG.TODO/signal/sigwaitinfo.c @@ -0,0 +1,31 @@ +/* Implementation of sigwaitinfo function from POSIX.1b. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +int +__sigwaitinfo (const sigset_t *set, siginfo_t *info) +{ + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__sigwaitinfo) +weak_alias (__sigwaitinfo, sigwaitinfo) + +stub_warning (sigwaitinfo) diff --git a/REORG.TODO/signal/sys/signal.h b/REORG.TODO/signal/sys/signal.h new file mode 100644 index 0000000000..2e602dad89 --- /dev/null +++ b/REORG.TODO/signal/sys/signal.h @@ -0,0 +1 @@ +#include <signal.h> diff --git a/REORG.TODO/signal/sysv_signal.c b/REORG.TODO/signal/sysv_signal.c new file mode 100644 index 0000000000..04de2cf9ab --- /dev/null +++ b/REORG.TODO/signal/sysv_signal.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> + +/* Set the handler for the signal SIG to HANDLER, + returning the old handler, or SIG_ERR on error. */ +__sighandler_t +__sysv_signal (int sig, __sighandler_t handler) +{ + /* Check signal extents to protect __sigismember. */ + if (handler == SIG_ERR || sig < 1 || sig >= NSIG) + { + __set_errno (EINVAL); + return SIG_ERR; + } + + __set_errno (ENOSYS); + + return SIG_ERR; +} +weak_alias (__sysv_signal, sysv_signal) + +stub_warning (sysv_signal) diff --git a/REORG.TODO/signal/tst-raise.c b/REORG.TODO/signal/tst-raise.c new file mode 100644 index 0000000000..5d540b8cef --- /dev/null +++ b/REORG.TODO/signal/tst-raise.c @@ -0,0 +1,61 @@ +/* Copyright (C) 2003-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <error.h> +#include <signal.h> +#include <stdlib.h> +#include <stdio.h> + +volatile int count; + +void +sh (int sig) +{ + ++count; +} + +int +main (void) +{ + struct sigaction sa; + sa.sa_handler = sh; + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + if (sigaction (SIGUSR1, &sa, NULL) < 0) + { + printf ("sigaction failed: %m\n"); + exit (1); + } + if (raise (SIGUSR1) < 0) + { + printf ("first raise failed: %m\n"); + exit (1); + } + if (raise (SIGUSR1) < 0) + { + printf ("second raise failed: %m\n"); + exit (1); + } + if (count != 2) + { + printf ("signal handler not called 2 times\n"); + exit (1); + } + exit (0); +} diff --git a/REORG.TODO/signal/tst-signal.c b/REORG.TODO/signal/tst-signal.c new file mode 100644 index 0000000000..6d3178792a --- /dev/null +++ b/REORG.TODO/signal/tst-signal.c @@ -0,0 +1,44 @@ +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int win = 0; + +static void +handler (int sig) +{ + printf ("Received signal %d (%s).\n", sig, strsignal(sig)); + win = 1; +} + +int +main (void) +{ + if (signal (SIGTERM, handler) == SIG_ERR) + { + perror ("signal: SIGTERM"); + exit (EXIT_FAILURE); + } + + puts ("Set handler."); + + printf ("Sending myself signal %d.\n", SIGTERM); + fflush (stdout); + + if (raise (SIGTERM) < 0) + { + perror ("raise: SIGTERM"); + exit (EXIT_FAILURE); + } + + if (!win) + { + puts ("Didn't get any signal. Test FAILED!"); + exit (EXIT_FAILURE); + } + + puts ("Got a signal. Test succeeded."); + + return EXIT_SUCCESS; +} diff --git a/REORG.TODO/signal/tst-sigset.c b/REORG.TODO/signal/tst-sigset.c new file mode 100644 index 0000000000..d47adcc0d4 --- /dev/null +++ b/REORG.TODO/signal/tst-sigset.c @@ -0,0 +1,43 @@ +/* Test sig*set functions. */ + +#include <signal.h> +#include <stdio.h> + +#define TEST_FUNCTION do_test () +static int +do_test (void) +{ + int result = 0; + int sig = -1; + +#define TRY(call) \ + if (call) \ + { \ + printf ("%s (sig = %d): %m\n", #call, sig); \ + result = 1; \ + } \ + else + + + sigset_t set; + TRY (sigemptyset (&set) != 0); + +#ifdef SIGRTMAX + int max_sig = SIGRTMAX; +#else + int max_sig = NSIG - 1; +#endif + + for (sig = 1; sig <= max_sig; ++sig) + { + TRY (sigismember (&set, sig) != 0); + TRY (sigaddset (&set, sig) != 0); + TRY (sigismember (&set, sig) == 0); + TRY (sigdelset (&set, sig) != 0); + TRY (sigismember (&set, sig) != 0); + } + + return result; +} + +#include "../test-skeleton.c" diff --git a/REORG.TODO/signal/tst-sigset2.c b/REORG.TODO/signal/tst-sigset2.c new file mode 100644 index 0000000000..f653323321 --- /dev/null +++ b/REORG.TODO/signal/tst-sigset2.c @@ -0,0 +1,184 @@ +/* sigset_SIG_HOLD_bug.c [BZ #1951] */ +#include <errno.h> +#include <error.h> +#include <inttypes.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> + +#define TEST_SIG SIGINT + + +/* Print mask of blocked signals for this process */ +static void +printSigMask (const char *msg) +{ + sigset_t currMask; + int sig; + int cnt; + + if (msg != NULL) + printf ("%s", msg); + + if (sigprocmask (SIG_BLOCK, NULL, &currMask) == -1) + error (1, errno, "sigaction"); + + cnt = 0; + for (sig = 1; sig < NSIG; sig++) + { + if (sigismember (&currMask, sig)) + { + cnt++; + printf ("\t\t%d (%s)\n", sig, strsignal (sig)); + } + } + + if (cnt == 0) + printf ("\t\t<empty signal set>\n"); +} /* printSigMask */ + +static void +handler (int sig) +{ + printf ("Caught signal %d\n", sig); + printSigMask ("Signal mask in handler\n"); + printf ("Handler returning\n"); + _exit (1); +} /* handler */ + +static void +printDisposition (sighandler_t disp) +{ + if (disp == SIG_HOLD) + printf ("SIG_HOLD"); + else if (disp == SIG_DFL) + printf ("SIG_DFL"); + else if (disp == SIG_IGN) + printf ("SIG_IGN"); + else + printf ("handled at %" PRIxPTR, (uintptr_t) disp); +} /* printDisposition */ + +static int +returnTest1 (void) +{ + sighandler_t prev; + + printf ("===== TEST 1 =====\n"); + printf ("Blocking signal with sighold()\n"); + if (sighold (TEST_SIG) == -1) + error (1, errno, "sighold"); + printSigMask ("Signal mask after sighold()\n"); + + printf ("About to use sigset() to establish handler\n"); + prev = sigset (TEST_SIG, handler); + if (prev == SIG_ERR) + error(1, errno, "sigset"); + + printf ("Previous disposition: "); + printDisposition (prev); + printf (" (should be SIG_HOLD)\n"); + if (prev != SIG_HOLD) + { + printf("TEST FAILED!!!\n"); + return 1; + } + return 0; +} /* returnTest1 */ + +static int +returnTest2 (void) +{ + sighandler_t prev; + + printf ("\n===== TEST 2 =====\n"); + + printf ("About to use sigset() to set SIG_HOLD\n"); + prev = sigset (TEST_SIG, SIG_HOLD); + if (prev == SIG_ERR) + error (1, errno, "sigset"); + + printf ("Previous disposition: "); + printDisposition (prev); + printf (" (should be SIG_DFL)\n"); + if (prev != SIG_DFL) + { + printf("TEST FAILED!!!\n"); + return 1; + } + return 0; +} /* returnTest2 */ + +static int +returnTest3 (void) +{ + sighandler_t prev; + + printf ("\n===== TEST 3 =====\n"); + + printf ("About to use sigset() to set SIG_HOLD\n"); + prev = sigset (TEST_SIG, SIG_HOLD); + if (prev == SIG_ERR) + error (1, errno, "sigset"); + + printf ("About to use sigset() to set SIG_HOLD (again)\n"); + prev = sigset (TEST_SIG, SIG_HOLD); + if (prev == SIG_ERR) + error (1, errno, "sigset"); + + printf ("Previous disposition: "); + printDisposition (prev); + printf (" (should be SIG_HOLD)\n"); + if (prev != SIG_HOLD) + { + printf("TEST FAILED!!!\n"); + return 1; + } + return 0; +} /* returnTest3 */ + +int +main (int argc, char *argv[]) +{ + pid_t childPid; + + childPid = fork(); + if (childPid == -1) + error (1, errno, "fork"); + + if (childPid == 0) + exit (returnTest1 ()); + + int status; + if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid) + error (1, errno, "waitpid"); + int result = !WIFEXITED (status) || WEXITSTATUS (status) != 0; + + childPid = fork(); + if (childPid == -1) + error (1, errno, "fork"); + + if (childPid == 0) + exit (returnTest2 ()); + + if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid) + error (1, errno, "waitpid"); + result |= !WIFEXITED (status) || WEXITSTATUS (status) != 0; + + childPid = fork(); + if (childPid == -1) + error (1, errno, "fork"); + + if (childPid == 0) + exit (returnTest3 ()); + + if (TEMP_FAILURE_RETRY (waitpid (childPid, &status, 0)) != childPid) + error (1, errno, "waitpid"); + result |= !WIFEXITED (status) || WEXITSTATUS (status) != 0; + + return result; +} /* main */ diff --git a/REORG.TODO/signal/tst-sigsimple.c b/REORG.TODO/signal/tst-sigsimple.c new file mode 100644 index 0000000000..0119fecb50 --- /dev/null +++ b/REORG.TODO/signal/tst-sigsimple.c @@ -0,0 +1,56 @@ +/* Copyright (C) 2003-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 2003. + + The GNU C 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. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <signal.h> +#include <stdio.h> +#include <string.h> + + +static int +do_test (void) +{ + int result = 0; + int e; + +#define RUN(test) \ + errno = 0; \ + e = test; \ + if (e != -1) \ + { \ + printf ("%s returned %d\n", #test, e); \ + result = 1; \ + } \ + else if (errno != EINVAL) \ + { \ + printf ("%s didn't set errno to EINVAL (%s instead)\n", \ + #test, strerror (errno)); \ + result = 1; \ + } + + RUN (sighold (-1)); + RUN (sighold (_NSIG + 100)); + + RUN (sigrelse (-1)); + RUN (sigrelse (_NSIG + 100)); + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |