2000-02-17 20:38:33 +01:00
|
|
|
/* signal.cc
|
|
|
|
|
2003-01-15 11:21:23 +01:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
Written by Steve Chamberlain of Cygnus Support, sac@cygnus.com
|
|
|
|
Significant changes by Sergey Okhapkin <sos@prospect.com.ru>
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#include "winsup.h"
|
2002-01-11 03:24:06 +01:00
|
|
|
#include <stdlib.h>
|
2000-08-22 05:58:47 +02:00
|
|
|
#include "cygerrno.h"
|
2000-09-08 04:56:55 +02:00
|
|
|
#include <sys/cygwin.h>
|
2000-08-22 07:10:20 +02:00
|
|
|
#include "sigproc.h"
|
|
|
|
#include "pinfo.h"
|
2003-09-07 07:18:01 +02:00
|
|
|
#include "hires.h"
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-10-15 03:37:07 +02:00
|
|
|
int sigcatchers; /* FIXME: Not thread safe. */
|
|
|
|
|
|
|
|
#define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL)
|
|
|
|
|
2000-10-21 06:53:49 +02:00
|
|
|
static inline void
|
|
|
|
set_sigcatchers (void (*oldsig) (int), void (*cursig) (int))
|
|
|
|
{
|
|
|
|
#ifdef DEBUGGING
|
|
|
|
int last_sigcatchers = sigcatchers;
|
|
|
|
#endif
|
|
|
|
if (!sigtrapped (oldsig) && sigtrapped (cursig))
|
|
|
|
sigcatchers++;
|
|
|
|
else if (sigtrapped (oldsig) && !sigtrapped (cursig))
|
|
|
|
sigcatchers--;
|
|
|
|
#ifdef DEBUGGING
|
|
|
|
if (last_sigcatchers != sigcatchers)
|
|
|
|
sigproc_printf ("last %d, old %d, cur %p, cur %p", last_sigcatchers,
|
|
|
|
sigcatchers, oldsig, cursig);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" _sig_func_ptr
|
2000-02-17 20:38:33 +01:00
|
|
|
signal (int sig, _sig_func_ptr func)
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2000-02-17 20:38:33 +01:00
|
|
|
_sig_func_ptr prev;
|
|
|
|
|
|
|
|
/* check that sig is in right range */
|
2001-02-16 19:49:20 +01:00
|
|
|
if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
syscall_printf ("SIG_ERR = signal (%d, %p)", sig, func);
|
|
|
|
return (_sig_func_ptr) SIG_ERR;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
prev = myself->getsig (sig).sa_handler;
|
|
|
|
myself->getsig (sig).sa_handler = func;
|
|
|
|
myself->getsig (sig).sa_mask = 0;
|
2001-11-08 18:49:52 +01:00
|
|
|
/* SA_RESTART is set to maintain BSD compatible signal behaviour by default.
|
2002-11-22 05:43:47 +01:00
|
|
|
This is also compatible with the behaviour of signal(2) in Linux. */
|
2001-11-08 18:49:52 +01:00
|
|
|
myself->getsig (sig).sa_flags |= SA_RESTART;
|
2000-10-21 06:53:49 +02:00
|
|
|
set_sigcatchers (prev, func);
|
2000-10-28 07:41:44 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
|
|
|
|
return prev;
|
|
|
|
}
|
|
|
|
|
2003-01-22 11:43:39 +01:00
|
|
|
extern "C" int
|
|
|
|
nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2003-01-22 11:43:39 +01:00
|
|
|
int res = 0;
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2001-05-22 18:22:36 +02:00
|
|
|
sigframe thisframe (mainthread);
|
2003-01-14 21:05:49 +01:00
|
|
|
pthread_testcancel ();
|
|
|
|
|
2003-09-07 07:18:01 +02:00
|
|
|
if ((unsigned int) rqtp->tv_sec > (HIRES_DELAY_MAX / 1000 - 1)
|
|
|
|
|| (unsigned int) rqtp->tv_nsec > 999999999)
|
2003-01-22 11:43:39 +01:00
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
return -1;
|
|
|
|
}
|
2003-09-07 07:18:01 +02:00
|
|
|
DWORD resolution = gtod.resolution ();
|
|
|
|
DWORD req = ((rqtp->tv_sec * 1000 + (rqtp->tv_nsec + 999999) / 1000000
|
|
|
|
+ resolution - 1) / resolution ) * resolution;
|
|
|
|
DWORD end_time = gtod.dmsecs () + req;
|
2003-01-22 11:43:39 +01:00
|
|
|
syscall_printf ("nanosleep (%ld)", req);
|
2001-06-03 05:13:14 +02:00
|
|
|
|
2003-01-22 11:43:39 +01:00
|
|
|
int rc = pthread::cancelable_wait (signal_arrived, req);
|
2003-09-07 07:18:01 +02:00
|
|
|
DWORD rem;
|
|
|
|
if ((rem = end_time - gtod.dmsecs ()) > HIRES_DELAY_MAX)
|
|
|
|
rem = 0;
|
2003-05-06 21:39:10 +02:00
|
|
|
if (rc == WAIT_OBJECT_0)
|
2003-01-22 11:43:39 +01:00
|
|
|
{
|
|
|
|
(void) thisframe.call_signal_handler ();
|
|
|
|
set_errno (EINTR);
|
|
|
|
res = -1;
|
|
|
|
}
|
2000-09-16 15:19:52 +02:00
|
|
|
|
2003-01-22 11:43:39 +01:00
|
|
|
if (rmtp)
|
|
|
|
{
|
|
|
|
rmtp->tv_sec = rem / 1000;
|
|
|
|
rmtp->tv_nsec = (rem % 1000) * 1000000;
|
|
|
|
}
|
2000-09-16 15:19:52 +02:00
|
|
|
|
2003-01-22 11:43:39 +01:00
|
|
|
syscall_printf ("%d = nanosleep (%ld, %ld)", res, req, rem);
|
2000-09-16 15:19:52 +02:00
|
|
|
return res;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" unsigned int
|
2003-01-22 11:43:39 +01:00
|
|
|
sleep (unsigned int seconds)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2003-01-22 11:43:39 +01:00
|
|
|
struct timespec req, rem;
|
|
|
|
req.tv_sec = seconds;
|
|
|
|
req.tv_nsec = 0;
|
|
|
|
nanosleep (&req, &rem);
|
2003-09-07 07:18:01 +02:00
|
|
|
return rem.tv_sec + (rem.tv_nsec > 0);
|
2003-01-22 11:43:39 +01:00
|
|
|
}
|
2003-01-14 21:05:49 +01:00
|
|
|
|
2003-01-22 11:43:39 +01:00
|
|
|
extern "C" unsigned int
|
|
|
|
usleep (unsigned int useconds)
|
|
|
|
{
|
|
|
|
struct timespec req;
|
|
|
|
req.tv_sec = useconds / 1000000;
|
|
|
|
req.tv_nsec = (useconds % 1000000) * 1000;
|
|
|
|
int res = nanosleep (&req, 0);
|
|
|
|
return res;
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigprocmask (int sig, const sigset_t *set, sigset_t *oldset)
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2000-02-17 20:38:33 +01:00
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("SIG_ERR = sigprocmask signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldset)
|
|
|
|
*oldset = myself->getsigmask ();
|
|
|
|
if (set)
|
|
|
|
{
|
|
|
|
sigset_t newmask = myself->getsigmask ();
|
|
|
|
switch (sig)
|
|
|
|
{
|
|
|
|
case SIG_BLOCK:
|
|
|
|
/* add set to current mask */
|
|
|
|
newmask |= *set;
|
|
|
|
break;
|
|
|
|
case SIG_UNBLOCK:
|
|
|
|
/* remove set from current mask */
|
|
|
|
newmask &= ~*set;
|
|
|
|
break;
|
|
|
|
case SIG_SETMASK:
|
|
|
|
/* just set it */
|
|
|
|
newmask = *set;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
set_errno (EINVAL);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
(void) set_process_mask (newmask);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
kill_worker (pid_t pid, int sig)
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2002-11-22 21:51:13 +01:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
int res = 0;
|
2000-07-29 18:24:59 +02:00
|
|
|
pinfo dest (pid);
|
2000-02-17 20:38:33 +01:00
|
|
|
BOOL sendSIGCONT;
|
|
|
|
|
|
|
|
if (!dest)
|
|
|
|
{
|
|
|
|
set_errno (ESRCH);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
dest->setthread2signal (NULL);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
if ((sendSIGCONT = (sig < 0)))
|
|
|
|
sig = -sig;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (dest == myself && !sendSIGCONT)
|
|
|
|
dest = myself_nowait_nonmain;
|
|
|
|
#endif
|
|
|
|
if (sig == 0)
|
2001-06-16 19:09:19 +02:00
|
|
|
{
|
|
|
|
res = proc_exists (dest) ? 0 : -1;
|
|
|
|
if (res < 0)
|
|
|
|
set_errno (ESRCH);
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
else if ((res = sig_send (dest, sig)))
|
|
|
|
{
|
|
|
|
sigproc_printf ("%d = sig_send, %E ", res);
|
|
|
|
res = -1;
|
|
|
|
}
|
2000-10-31 00:19:45 +01:00
|
|
|
else if (sendSIGCONT)
|
2000-02-17 20:38:33 +01:00
|
|
|
(void) sig_send (dest, SIGCONT);
|
|
|
|
|
|
|
|
syscall_printf ("%d = kill_worker (%d, %d)", res, pid, sig);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-08-29 04:06:49 +02:00
|
|
|
int
|
2002-10-20 06:15:50 +02:00
|
|
|
raise (int sig)
|
2000-08-29 04:06:49 +02:00
|
|
|
{
|
2002-10-20 06:15:50 +02:00
|
|
|
return kill (myself->pid, sig);
|
2000-08-29 04:06:49 +02:00
|
|
|
}
|
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
int
|
2002-10-20 06:15:50 +02:00
|
|
|
kill (pid_t pid, int sig)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2002-01-11 03:24:06 +01:00
|
|
|
sigframe thisframe (mainthread);
|
2000-02-17 20:38:33 +01:00
|
|
|
syscall_printf ("kill (%d, %d)", pid, sig);
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Silently ignore stop signals from a member of orphaned process group.
|
|
|
|
FIXME: Why??? */
|
2002-09-23 02:31:31 +02:00
|
|
|
if (ISSTATE (myself, PID_ORPHANED) &&
|
2000-02-17 20:38:33 +01:00
|
|
|
(sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU))
|
|
|
|
sig = 0;
|
|
|
|
|
|
|
|
return (pid > 0) ? kill_worker (pid, sig) : kill_pgrp (-pid, sig);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
kill_pgrp (pid_t pid, int sig)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
int found = 0;
|
|
|
|
int killself = 0;
|
2002-01-11 03:24:06 +01:00
|
|
|
sigframe thisframe (mainthread);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2001-04-01 02:06:17 +02:00
|
|
|
sigproc_printf ("pid %d, signal %d", pid, sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-07-29 18:24:59 +02:00
|
|
|
winpids pids;
|
|
|
|
for (unsigned i = 0; i < pids.npids; i++)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2000-11-05 07:42:23 +01:00
|
|
|
_pinfo *p = pids[i];
|
2000-02-17 20:38:33 +01:00
|
|
|
|
|
|
|
if (!proc_exists (p))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Is it a process we want to kill? */
|
2001-01-17 15:57:09 +01:00
|
|
|
if ((pid == 0 && (p->pgid != myself->pgid || p->ctty != myself->ctty)) ||
|
2001-09-07 23:32:07 +02:00
|
|
|
(pid > 1 && p->pgid != pid) ||
|
2002-09-23 02:31:31 +02:00
|
|
|
(sig < 0 && NOTSTATE (p, PID_STOPPED)))
|
2000-10-31 00:19:45 +01:00
|
|
|
continue;
|
2000-02-17 20:38:33 +01:00
|
|
|
sigproc_printf ("killing pid %d, pgrp %d, p->ctty %d, myself->ctty %d",
|
|
|
|
p->pid, p->pgid, p->ctty, myself->ctty);
|
|
|
|
if (p == myself)
|
|
|
|
killself++;
|
|
|
|
else if (kill_worker (p->pid, sig))
|
|
|
|
res = -1;
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (killself && kill_worker (myself->pid, sig))
|
|
|
|
res = -1;
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
{
|
|
|
|
set_errno (ESRCH);
|
|
|
|
res = -1;
|
|
|
|
}
|
|
|
|
syscall_printf ("%d = kill (%d, %d)", res, pid, sig);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2001-02-08 00:48:09 +01:00
|
|
|
killpg (pid_t pgrp, int sig)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2002-10-20 06:15:50 +02:00
|
|
|
return kill (-pgrp, sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
|
2002-01-11 03:24:06 +01:00
|
|
|
extern "C" void
|
|
|
|
abort (void)
|
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2002-01-11 03:24:06 +01:00
|
|
|
sigframe thisframe (mainthread);
|
|
|
|
/* Flush all streams as per SUSv2.
|
|
|
|
From my reading of this document, this isn't strictly correct.
|
|
|
|
The streams are supposed to be flushed prior to exit. However,
|
|
|
|
if there is I/O in any signal handler that will not necessarily
|
|
|
|
be flushed.
|
|
|
|
However this is the way FreeBSD does it, and it is much easier to
|
|
|
|
do things this way, so... */
|
2003-06-16 05:24:13 +02:00
|
|
|
if (_REENT->__cleanup)
|
|
|
|
_REENT->__cleanup (_REENT);
|
2002-01-11 03:24:06 +01:00
|
|
|
|
|
|
|
/* Ensure that SIGABRT can be caught regardless of blockage. */
|
|
|
|
sigset_t sig_mask;
|
|
|
|
sigfillset (&sig_mask);
|
|
|
|
sigdelset (&sig_mask, SIGABRT);
|
|
|
|
set_process_mask (sig_mask);
|
|
|
|
|
2002-10-20 06:15:50 +02:00
|
|
|
raise (SIGABRT);
|
2002-01-11 03:24:06 +01:00
|
|
|
(void) thisframe.call_signal_handler (); /* Call any signal handler */
|
|
|
|
do_exit (1); /* signal handler didn't exit. Goodbye. */
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-10-15 03:37:07 +02:00
|
|
|
sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2003-08-19 06:10:42 +02:00
|
|
|
sig_dispatch_pending ();
|
2001-04-01 02:06:17 +02:00
|
|
|
sigproc_printf ("signal %d, newact %p, oldact %p", sig, newact, oldact);
|
2000-02-17 20:38:33 +01:00
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig < 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("SIG_ERR = sigaction signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2000-10-15 03:37:07 +02:00
|
|
|
struct sigaction oa = myself->getsig (sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
|
2000-10-15 03:37:07 +02:00
|
|
|
if (newact)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
2001-02-16 19:49:20 +01:00
|
|
|
if (sig == SIGKILL || sig == SIGSTOP)
|
2000-02-17 20:38:33 +01:00
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
return -1;
|
|
|
|
}
|
2000-10-15 03:37:07 +02:00
|
|
|
myself->getsig (sig) = *newact;
|
|
|
|
if (newact->sa_handler == SIG_IGN)
|
2000-02-17 20:38:33 +01:00
|
|
|
sig_clear (sig);
|
2000-10-15 03:37:07 +02:00
|
|
|
if (newact->sa_handler == SIG_DFL && sig == SIGCHLD)
|
2000-02-17 20:38:33 +01:00
|
|
|
sig_clear (sig);
|
2000-10-21 06:53:49 +02:00
|
|
|
set_sigcatchers (oa.sa_handler, newact->sa_handler);
|
2003-09-01 04:05:32 +02:00
|
|
|
if (sig == SIGCHLD)
|
|
|
|
{
|
|
|
|
myself->process_state &= ~PID_NOCLDSTOP;
|
|
|
|
if (newact->sa_flags & SA_NOCLDSTOP);
|
|
|
|
myself->process_state |= PID_NOCLDSTOP;
|
|
|
|
}
|
2000-02-17 20:38:33 +01:00
|
|
|
}
|
|
|
|
|
2000-10-15 03:37:07 +02:00
|
|
|
if (oldact)
|
|
|
|
*oldact = oa;
|
2000-10-02 21:19:21 +02:00
|
|
|
|
2000-02-17 20:38:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigaddset (sigset_t *set, const int sig)
|
|
|
|
{
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig <= 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("SIG_ERR = sigaddset signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*set |= SIGTOMASK (sig);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigdelset (sigset_t *set, const int sig)
|
|
|
|
{
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig <= 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*set &= ~SIGTOMASK (sig);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigismember (const sigset_t *set, int sig)
|
|
|
|
{
|
|
|
|
/* check that sig is in right range */
|
|
|
|
if (sig <= 0 || sig >= NSIG)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
2001-04-01 02:06:17 +02:00
|
|
|
syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig);
|
2000-02-17 20:38:33 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*set & SIGTOMASK (sig))
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigemptyset (sigset_t *set)
|
|
|
|
{
|
|
|
|
*set = (sigset_t) 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigfillset (sigset_t *set)
|
|
|
|
{
|
|
|
|
*set = ~((sigset_t) 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigsuspend (const sigset_t *set)
|
|
|
|
{
|
|
|
|
return handle_sigsuspend (*set);
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
sigpause (int signal_mask)
|
|
|
|
{
|
|
|
|
return handle_sigsuspend ((sigset_t) signal_mask);
|
|
|
|
}
|
|
|
|
|
2000-10-02 21:19:21 +02:00
|
|
|
extern "C" int
|
2000-02-17 20:38:33 +01:00
|
|
|
pause (void)
|
|
|
|
{
|
|
|
|
return handle_sigsuspend (myself->getsigmask ());
|
|
|
|
}
|
2002-11-15 20:04:36 +01:00
|
|
|
|
|
|
|
extern "C" int
|
|
|
|
siginterrupt (int sig, int flag)
|
|
|
|
{
|
|
|
|
struct sigaction act;
|
|
|
|
(void)sigaction(sig, NULL, &act);
|
|
|
|
if (flag)
|
|
|
|
act.sa_flags &= ~SA_RESTART;
|
|
|
|
else
|
|
|
|
act.sa_flags |= SA_RESTART;
|
|
|
|
return sigaction(sig, &act, NULL);
|
|
|
|
}
|
|
|
|
|