BSD signal blocking
Bruno Haible
haible@ilog.fr
Mon Jul 10 05:35:00 GMT 2000
Programs that make use of BSD signal blocking functions, like the following
one, cannot be compiled with CC="gcc -ansi" on Linux, because the libc is
missing the sigmask() function. Therefore sigmask() should be added to the
libc.
Sample program:
#include <signal.h>
int main()
{
int wasblocked = ((sigblock(0) & sigmask(SIGALRM)) != 0);
exit(wasblocked);
}
It produces:
$ gcc foo.c
$ gcc -ansi foo.c
/tmp/cclSazAu.o: In function `main':
/tmp/cclSazAu.o(.text+0x1c): undefined reference to `sigmask'
collect2: ld returned 1 exit status
Here is a fix.
2000-07-08 Bruno Haible <haible@clisp.cons.org>
* sysdeps/generic/sigmask.c: New file.
* signal/Makefile (routines): Add sigmask.
* signal/Versions: Add sigmask.
*** sysdeps/generic/sigmask.c.bak Sat Jul 8 22:32:30 2000
--- sysdeps/generic/sigmask.c Sat Jul 8 22:38:35 2000
***************
*** 0 ****
--- 1,28 ----
+ /* Copyright (C) 2000 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ #include <signal.h>
+
+ #undef sigmask
+
+ /* Compute mask for signal SIG. */
+ int
+ sigmask (int sig)
+ {
+ return __sigmask (sig);
+ }
*** signal/Makefile.bak Tue Sep 7 17:06:02 1999
--- signal/Makefile Sat Jul 8 22:35:52 2000
***************
*** 28,34 ****
routines := signal raise killpg \
sigaction sigprocmask kill \
sigpending sigsuspend sigwait \
! sigblock sigsetmask sigpause sigvec \
sigstack sigaltstack sigintr \
sigsetops sigempty sigfillset sigaddset sigdelset sigismem \
sigreturn \
--- 28,34 ----
routines := signal raise killpg \
sigaction sigprocmask kill \
sigpending sigsuspend sigwait \
! sigmask sigblock sigsetmask sigpause sigvec \
sigstack sigaltstack sigintr \
sigsetops sigempty sigfillset sigaddset sigdelset sigismem \
sigreturn \
*** signal/Versions.bak Mon Feb 28 11:38:00 2000
--- signal/Versions Sat Jul 8 22:37:45 2000
***************
*** 48,52 ****
--- 48,55 ----
GLIBC_2.2 {
# Needed to provide a pointer to the XPG sigpause function.
__xpg_sigpause;
+
+ # s*
+ sigmask;
}
}
More information about the Libc-alpha
mailing list