diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3d618cabd..23855f2b3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2006-02-16 Corinna Vinschen + + * cygwin.din: Export sigignore and sigset. + * exceptions.cc (sigset): New function. + (sigignore): New function. + * include/cygwin/signal.h (SIG_HOLD): Define. + (sigignore): Declare. + (sigset): Declare. + * include/cygwin/version.h: Bump API minor number to 154. + 2006-02-13 Igor Peshansky * include/mntent.h: Add missing #include. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 8880c7b0b..7bbe7b1ee 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1284,6 +1284,7 @@ sigdelset SIGFE sigemptyset NOSIGFE sigfillset NOSIGFE sighold SIGFE +sigignore SIGFE sigqueue SIGFE siginterrupt SIGFE sigismember SIGFE @@ -1294,6 +1295,7 @@ sigpause SIGFE sigpending SIGFE sigprocmask SIGFE sigrelse SIGFE +sigset SIGFE sigsuspend SIGFE sigwait SIGFE sigwaitinfo SIGFE diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 4162ebd6b..3f2c13c88 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1021,6 +1021,50 @@ sigrelse (int sig) return 0; } +extern "C" _sig_func_ptr +sigset (int sig, _sig_func_ptr func) +{ + sig_dispatch_pending (); + _sig_func_ptr prev; + + /* check that sig is in right range */ + if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) + { + set_errno (EINVAL); + syscall_printf ("SIG_ERR = sigset (%d, %p)", sig, func); + return (_sig_func_ptr) SIG_ERR; + } + + mask_sync.acquire (INFINITE); + sigset_t mask = myself->getsigmask (); + /* If sig was in the signal mask return SIG_HOLD, otherwise return the + previous disposition. */ + if (sigismember (&mask, sig)) + prev = SIG_HOLD; + else + prev = global_sigs[sig].sa_handler; + /* If func is SIG_HOLD, add sig to the signal mask, otherwise set the + disposition to func and remove sig from the signal mask. */ + if (func == SIG_HOLD) + sigaddset (&mask, sig); + else + { + /* No error checking. The test which could return SIG_ERR has already + been made above. */ + signal (sig, func); + sigdelset (&mask, sig); + } + set_signal_mask (mask, myself->getsigmask ()); + mask_sync.release (); + return prev; +} + +extern "C" int +sigignore (int sig) +{ + return sigset (sig, SIG_IGN) == SIG_ERR ? -1 : 0; +} + /* Update the signal mask for this process and return the old mask. Called from sigdelayed */ extern "C" sigset_t diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index fd6110969..0e0aab7d3 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -254,10 +254,15 @@ struct sigaction #define SIGRTMAX ((SIGRTMIN) + 0) #define NSIG 33 /* signal 0 implied */ +#define SIG_HOLD ((_sig_func_ptr)2) /* Signal in signal mask */ + int sigwait (const sigset_t *, int *); int sigwaitinfo (const sigset_t *, siginfo_t *); int sighold (int); +int sigignore (int); int sigrelse (int); +_sig_func_ptr sigset (int, _sig_func_ptr); + int sigqueue(pid_t, int, const union sigval); int siginterrupt (int, int); #ifdef __cplusplus diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index f6c584486..0385f3cf8 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -286,12 +286,13 @@ details. */ 151: Export __opendir_with_d_ino 152: Revert to having d_ino in dirent unconditionally. 153: Export updwtmpx, Implement CW_SETUP_WINENV. + 154: Export sigset, sigignore. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 153 +#define CYGWIN_VERSION_API_MINOR 154 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible