aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-02-18 14:08:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-02-18 14:08:37 +0000
commitada0ce07316cd9a467616febc6d93d4851ba8978 (patch)
tree9a9af95c91025ee9b8c170f26cb58d296dd3a4bc
parentdfb28cbab77bc95f9d6df8c81ca529c1fe9dd48f (diff)
downloadnewlib-ada0ce07316cd9a467616febc6d93d4851ba8978.zip
newlib-ada0ce07316cd9a467616febc6d93d4851ba8978.tar.gz
newlib-ada0ce07316cd9a467616febc6d93d4851ba8978.tar.bz2
* exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and
use either main sigmask or current thread sigmask. (set_process_mask): Ditto. (sighold): Ditto. (sigrelse): Ditto. (sigset): Ditto. (set_process_mask_delta): Ditto. (_cygtls::call_signal_handler): Ditto. * fhandler_process.cc (format_process_status): Ditto. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * pinfo.h (class pinfo): Ditto. * select.cc (pselect): Ditto. * signal.cc (sigprocmask): Ditto. (abort): Ditto. (sigpause): Ditto. (sigsend): Ditto. (wait_sig): Ditto. * sigproc.cc (sig_send): Ditto. (pending_signals::add): Ditto. (wait_sig): Ditto. * thread.h (pthread::parent_tls): New member. * thread.cc (pthread::pthread): Record parent_tls here. (pthread::thread_init_wrapper): Initialize sigmask from parent thread.
-rw-r--r--winsup/cygwin/ChangeLog26
-rw-r--r--winsup/cygwin/exceptions.cc25
-rw-r--r--winsup/cygwin/fhandler_process.cc3
-rw-r--r--winsup/cygwin/fhandler_termios.cc2
-rw-r--r--winsup/cygwin/pinfo.h12
-rw-r--r--winsup/cygwin/select.cc6
-rw-r--r--winsup/cygwin/signal.cc6
-rw-r--r--winsup/cygwin/sigproc.cc8
-rw-r--r--winsup/cygwin/thread.cc2
-rw-r--r--winsup/cygwin/thread.h1
10 files changed, 54 insertions, 37 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 8494c22..eab0418 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,29 @@
+2008-02-15 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * exceptions.cc (handle_sigsuspend): Eliminate thread signal mask and
+ use either main sigmask or current thread sigmask.
+ (set_process_mask): Ditto.
+ (sighold): Ditto.
+ (sigrelse): Ditto.
+ (sigset): Ditto.
+ (set_process_mask_delta): Ditto.
+ (_cygtls::call_signal_handler): Ditto.
+ * fhandler_process.cc (format_process_status): Ditto.
+ * fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
+ * pinfo.h (class pinfo): Ditto.
+ * select.cc (pselect): Ditto.
+ * signal.cc (sigprocmask): Ditto.
+ (abort): Ditto.
+ (sigpause): Ditto.
+ (sigsend): Ditto.
+ (wait_sig): Ditto.
+ * sigproc.cc (sig_send): Ditto.
+ (pending_signals::add): Ditto.
+ (wait_sig): Ditto.
+ * thread.h (pthread::parent_tls): New member.
+ * thread.cc (pthread::pthread): Record parent_tls here.
+ (pthread::thread_init_wrapper): Initialize sigmask from parent thread.
+
2008-02-13 Christopher Faylor <me+cygwin@cgf.cx>
* thread.cc (pthread_kill): Deal with signal 0 as per POSIX and also
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index d4c14e2..ad0af38 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -687,9 +687,9 @@ handle_sigsuspend (sigset_t tempmask)
return -1;
}
- sigset_t oldmask = myself->getsigmask (); // Remember for restoration
+ sigset_t oldmask = _my_tls.sigmask; // Remember for restoration
- set_signal_mask (tempmask, myself->getsigmask ());
+ set_signal_mask (tempmask, _my_tls.sigmask);
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
@@ -999,8 +999,7 @@ ctrl_c_handler (DWORD type)
extern "C" void __stdcall
set_process_mask (sigset_t newmask)
{
- set_signal_mask (newmask, myself->getsigmask ());
-sigproc_printf ("mask now %p\n", myself->getsigmask ());
+ set_signal_mask (newmask, _my_tls.sigmask);
}
extern "C" int
@@ -1014,9 +1013,9 @@ sighold (int sig)
return -1;
}
mask_sync.acquire (INFINITE);
- sigset_t mask = myself->getsigmask ();
+ sigset_t mask = _my_tls.sigmask;
sigaddset (&mask, sig);
- set_signal_mask (mask, myself->getsigmask ());
+ set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return 0;
}
@@ -1032,9 +1031,9 @@ sigrelse (int sig)
return -1;
}
mask_sync.acquire (INFINITE);
- sigset_t mask = myself->getsigmask ();
+ sigset_t mask = _my_tls.sigmask;
sigdelset (&mask, sig);
- set_signal_mask (mask, myself->getsigmask ());
+ set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return 0;
}
@@ -1054,7 +1053,7 @@ sigset (int sig, _sig_func_ptr func)
}
mask_sync.acquire (INFINITE);
- sigset_t mask = myself->getsigmask ();
+ sigset_t mask = _my_tls.sigmask;
/* If sig was in the signal mask return SIG_HOLD, otherwise return the
previous disposition. */
if (sigismember (&mask, sig))
@@ -1072,7 +1071,7 @@ sigset (int sig, _sig_func_ptr func)
signal (sig, func);
sigdelset (&mask, sig);
}
- set_signal_mask (mask, myself->getsigmask ());
+ set_signal_mask (mask, _my_tls.sigmask);
mask_sync.release ();
return prev;
}
@@ -1094,11 +1093,11 @@ set_process_mask_delta ()
if (_my_tls.deltamask & SIG_NONMASKABLE)
oldmask = _my_tls.oldmask; /* from handle_sigsuspend */
else
- oldmask = myself->getsigmask ();
+ oldmask = _my_tls.sigmask;
newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE;
sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
_my_tls.deltamask);
- myself->setsigmask (newmask);
+ _my_tls.sigmask = newmask;
mask_sync.release ();
return oldmask;
}
@@ -1366,7 +1365,7 @@ _cygtls::call_signal_handler ()
sigact (thissig, &thissi, NULL);
}
incyg = 1;
- set_signal_mask (this_oldmask, myself->getsigmask ());
+ set_signal_mask (this_oldmask, _my_tls.sigmask);
if (this_errno >= 0)
set_errno (this_errno);
}
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index 852e891..b07f401 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -20,6 +20,7 @@ details. */
#include "pinfo.h"
#include "shared_info.h"
#include "dtable.h"
+#include "cygtls.h"
#include "cygheap.h"
#include "ntdll.h"
#include <sys/param.h>
@@ -824,7 +825,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
p->uid, p->uid, p->uid, p->uid,
p->gid, p->gid, p->gid, p->gid,
vmsize >> 10, 0, vmrss >> 10, vmdata >> 10, 0, vmtext >> 10, vmlib >> 10,
- 0, 0, p->getsigmask ()
+ 0, 0, _my_tls.sigmask
);
}
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index 0a6e05c..3b51160 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -156,7 +156,7 @@ fhandler_termios::bg_check (int sig)
int pgid_gone = !pid_exists (myself->pgid);
int sigs_ignored =
((void *) global_sigs[sig].sa_handler == (void *) SIG_IGN) ||
- (myself->getsigmask () & SIGTOMASK (sig));
+ (_main_tls->sigmask & SIGTOMASK (sig));
if (pgid_gone)
goto setEIO;
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 0367f38..e5abf12 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -97,16 +97,6 @@ public:
inline void set_has_pgid_children (bool val) {has_pgid_children = val;}
- inline sigset_t& getsigmask ()
- {
- return sig_mask;
- }
-
- inline void setsigmask (sigset_t mask)
- {
- sig_mask = mask;
- }
-
commune_result commune_request (__uint32_t, ...);
bool alive ();
fhandler_pipe *pipe_fhandler (HANDLE, size_t &);
@@ -129,8 +119,6 @@ public:
HANDLE sendsig;
HANDLE exec_sendsig;
DWORD exec_dwProcessId;
-private:
- sigset_t sig_mask;
public:
HANDLE wr_proc_pipe;
DWORD wr_proc_pipe_owner;
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 63215ca..4aafd5f 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -164,7 +164,7 @@ pselect(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *ts, const sigset_t *set)
{
struct timeval tv;
- sigset_t oldset = myself->getsigmask ();
+ sigset_t oldset = _my_tls.sigmask;
myfault efault;
if (efault.faulted (EFAULT))
@@ -175,11 +175,11 @@ pselect(int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
tv.tv_usec = ts->tv_nsec / 1000;
}
if (set)
- set_signal_mask (*set, myself->getsigmask ());
+ set_signal_mask (*set, _my_tls.sigmask);
int ret = cygwin_select (maxfds, readfds, writefds, exceptfds,
ts ? &tv : NULL);
if (set)
- set_signal_mask (oldset, myself->getsigmask ());
+ set_signal_mask (oldset, _my_tls.sigmask);
return ret;
}
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 3765cff..707ab0d 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -147,7 +147,7 @@ usleep (useconds_t useconds)
extern "C" int
sigprocmask (int how, const sigset_t *set, sigset_t *oldset)
{
- return handle_sigprocmask (how, set, oldset, myself->getsigmask ());
+ return handle_sigprocmask (how, set, oldset, _my_tls.sigmask);
}
int __stdcall
@@ -342,7 +342,7 @@ abort (void)
sigset_t sig_mask;
sigfillset (&sig_mask);
sigdelset (&sig_mask, SIGABRT);
- set_signal_mask (sig_mask, myself->getsigmask ());
+ set_signal_mask (sig_mask, _my_tls.sigmask);
raise (SIGABRT);
_my_tls.call_signal_handler (); /* Call any signal handler */
@@ -485,7 +485,7 @@ sigpause (int signal_mask)
extern "C" int
pause (void)
{
- return handle_sigsuspend (myself->getsigmask ());
+ return handle_sigsuspend (_my_tls.sigmask);
}
extern "C" int
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 4bc7594..5eaac04 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -663,7 +663,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
else if (si.si_signo == __SIGPENDING)
pack.mask = &pending;
else if (si.si_signo == __SIGFLUSH || si.si_signo > 0)
- pack.mask = &myself->getsigmask ();
+ pack.mask = &_my_tls.sigmask;
else
pack.mask = NULL;
@@ -1118,7 +1118,7 @@ pending_signals::add (sigpacket& pack)
return;
se = sigs + pack.si.si_signo;
*se = pack;
- se->mask = &myself->getsigmask ();
+ se->mask = &pack.tls->sigmask;
se->next = NULL;
if (end)
end->next = se;
@@ -1199,7 +1199,7 @@ wait_sig (VOID *)
sigset_t dummy_mask;
if (!pack.mask)
{
- dummy_mask = myself->getsigmask ();
+ dummy_mask = _main_tls->sigmask;
pack.mask = &dummy_mask;
}
@@ -1218,7 +1218,7 @@ wait_sig (VOID *)
unsigned bit;
sigq.reset ();
while ((q = sigq.next ()))
- if (myself->getsigmask () & (bit = SIGTOMASK (q->si.si_signo)))
+ if (pack.tls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
*pack.mask |= bit;
break;
case __SIGHOLD:
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index f5226a5..f9501f8 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -374,6 +374,7 @@ pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
{
if (this != pthread_null::get_null_pthread ())
threads.insert (this);
+ parent_tls = &_my_tls;
}
pthread::~pthread ()
@@ -1909,6 +1910,7 @@ pthread::thread_init_wrapper (void *arg)
// if thread is detached force cleanup on exit
if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL)
thread->joiner = thread;
+ _my_tls.sigmask = thread->parent_tls->sigmask;
thread->mutex.unlock ();
thread_printf ("started thread %p %p %p %p %p %p", arg, &_my_tls.local_clib,
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index ed2ec54..92164fb 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -430,6 +430,7 @@ private:
DWORD thread_id;
__pthread_cleanup_handler *cleanup_stack;
pthread_mutex mutex;
+ _cygtls *parent_tls;
void suspend_except_self ();
void resume ();