4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-18 23:12:15 +08:00

* signal.cc (sigaction): Allow new action == oldaction.

This commit is contained in:
Christopher Faylor 2000-10-02 19:19:21 +00:00
parent 63c05d8ce7
commit 17e8632267
2 changed files with 31 additions and 37 deletions

View File

@ -1,3 +1,7 @@
Mon Oct 2 15:15:01 2000 Christopher Faylor <cgf@cygnus.com>
* signal.cc (sigaction): Allow new action == oldaction.
Mon Oct 2 11:05:00 2000 Corinna Vinschen <corinna@vinschen.de> Mon Oct 2 11:05:00 2000 Corinna Vinschen <corinna@vinschen.de>
* fhandler_mem.cc: Load ntdll functions via autoload method. * fhandler_mem.cc: Load ntdll functions via autoload method.

View File

@ -19,8 +19,7 @@ details. */
#include "sigproc.h" #include "sigproc.h"
#include "pinfo.h" #include "pinfo.h"
extern "C" extern "C" _sig_func_ptr
_sig_func_ptr
signal (int sig, _sig_func_ptr func) signal (int sig, _sig_func_ptr func)
{ {
_sig_func_ptr prev; _sig_func_ptr prev;
@ -33,15 +32,14 @@ signal (int sig, _sig_func_ptr func)
return (_sig_func_ptr) SIG_ERR; return (_sig_func_ptr) SIG_ERR;
} }
prev = myself->getsig(sig).sa_handler; prev = myself->getsig (sig).sa_handler;
myself->getsig(sig).sa_handler = func; myself->getsig (sig).sa_handler = func;
myself->getsig(sig).sa_mask = 0; myself->getsig (sig).sa_mask = 0;
syscall_printf ("%p = signal (%d, %p)", prev, sig, func); syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
return prev; return prev;
} }
extern "C" extern "C" unsigned int
unsigned int
sleep (unsigned int seconds) sleep (unsigned int seconds)
{ {
int rc; int rc;
@ -62,8 +60,7 @@ sleep (unsigned int seconds)
return res; return res;
} }
extern "C" extern "C" unsigned int
unsigned int
usleep (unsigned int useconds) usleep (unsigned int useconds)
{ {
syscall_printf ("usleep (%d)", useconds); syscall_printf ("usleep (%d)", useconds);
@ -72,8 +69,7 @@ usleep (unsigned int useconds)
return 0; return 0;
} }
extern "C" extern "C" int
int
sigprocmask (int sig, const sigset_t *set, sigset_t *oldset) sigprocmask (int sig, const sigset_t *set, sigset_t *oldset)
{ {
/* check that sig is in right range */ /* check that sig is in right range */
@ -125,7 +121,7 @@ kill_worker (pid_t pid, int sig)
return -1; return -1;
} }
dest->setthread2signal(NULL); dest->setthread2signal (NULL);
if ((sendSIGCONT = (sig < 0))) if ((sendSIGCONT = (sig < 0)))
sig = -sig; sig = -sig;
@ -221,19 +217,19 @@ kill_pgrp (pid_t pid, int sig)
return res; return res;
} }
extern "C" extern "C" int
int
killpg (int pgrp, int sig) killpg (int pgrp, int sig)
{ {
return _kill (-pgrp, sig); return _kill (-pgrp, sig);
} }
extern "C" extern "C" int
int
sigaction (int sig, sigaction (int sig,
const struct sigaction *newaction, const struct sigaction *newaction,
struct sigaction *oldaction) struct sigaction *oldaction)
{ {
struct sigaction out_oldaction;
/* check that sig is in right range */ /* check that sig is in right range */
if (sig < 0 || sig >= NSIG) if (sig < 0 || sig >= NSIG)
{ {
@ -243,7 +239,7 @@ sigaction (int sig,
} }
if (oldaction) if (oldaction)
*oldaction = myself->getsig(sig); out_oldaction = myself->getsig (sig);
if (newaction) if (newaction)
{ {
@ -252,18 +248,20 @@ sigaction (int sig,
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
myself->getsig(sig) = *newaction; myself->getsig (sig) = *newaction;
if (newaction->sa_handler == SIG_IGN) if (newaction->sa_handler == SIG_IGN)
sig_clear (sig); sig_clear (sig);
if (newaction->sa_handler == SIG_DFL && sig == SIGCHLD) if (newaction->sa_handler == SIG_DFL && sig == SIGCHLD)
sig_clear (sig); sig_clear (sig);
} }
if (oldaction)
*oldaction = out_oldaction;
return 0; return 0;
} }
extern "C" extern "C" int
int
sigaddset (sigset_t *set, const int sig) sigaddset (sigset_t *set, const int sig)
{ {
/* check that sig is in right range */ /* check that sig is in right range */
@ -278,8 +276,7 @@ sigaddset (sigset_t *set, const int sig)
return 0; return 0;
} }
extern "C" extern "C" int
int
sigdelset (sigset_t *set, const int sig) sigdelset (sigset_t *set, const int sig)
{ {
/* check that sig is in right range */ /* check that sig is in right range */
@ -294,8 +291,7 @@ sigdelset (sigset_t *set, const int sig)
return 0; return 0;
} }
extern "C" extern "C" int
int
sigismember (const sigset_t *set, int sig) sigismember (const sigset_t *set, int sig)
{ {
/* check that sig is in right range */ /* check that sig is in right range */
@ -312,50 +308,44 @@ sigismember (const sigset_t *set, int sig)
return 0; return 0;
} }
extern "C" extern "C" int
int
sigemptyset (sigset_t *set) sigemptyset (sigset_t *set)
{ {
*set = (sigset_t) 0; *set = (sigset_t) 0;
return 0; return 0;
} }
extern "C" extern "C" int
int
sigfillset (sigset_t *set) sigfillset (sigset_t *set)
{ {
*set = ~((sigset_t) 0); *set = ~((sigset_t) 0);
return 0; return 0;
} }
extern "C" extern "C" int
int
sigpending (sigset_t *set) sigpending (sigset_t *set)
{ {
unsigned bit; unsigned bit;
*set = 0; *set = 0;
for (int sig = 1; sig < NSIG; sig++) for (int sig = 1; sig < NSIG; sig++)
if (*myself->getsigtodo(sig) && myself->getsigmask () & (bit = SIGTOMASK (sig))) if (*myself->getsigtodo (sig) && myself->getsigmask () & (bit = SIGTOMASK (sig)))
*set |= bit; *set |= bit;
return 0; return 0;
} }
extern "C" extern "C" int
int
sigsuspend (const sigset_t *set) sigsuspend (const sigset_t *set)
{ {
return handle_sigsuspend (*set); return handle_sigsuspend (*set);
} }
extern "C" extern "C" int
int
sigpause (int signal_mask) sigpause (int signal_mask)
{ {
return handle_sigsuspend ((sigset_t) signal_mask); return handle_sigsuspend ((sigset_t) signal_mask);
} }
extern "C" extern "C" int
int
pause (void) pause (void)
{ {
return handle_sigsuspend (myself->getsigmask ()); return handle_sigsuspend (myself->getsigmask ());