Date: Tue, 5 Feb 2002 00:26:39 -0500 (EST) From: Daniel Eischen <eischen@pcnet1.pcnet.com> To: callum.gibson@db.com Cc: hackers@FreeBSD.ORG Subject: Re: pthread_sigmask problem Message-ID: <Pine.GSO.4.10.10202050010120.3489-100000@pcnet1.pcnet.com> In-Reply-To: <20020205040208.75763.qmail@merton.aus.deuba.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 5 Feb 2002 callum.gibson@db.com wrote: > Thanks, Dan. (I saw your name come up in the archives next to a lot of > threads/signals posts while I was looking for an answer to this so I > wondered if you'd answer. :-) > > eischen@pcnet1.pcnet.com writes: > }> However, it seems that signals such as SIGPIPE, SIGINT, etc will still > }> kill the process. I also tried replacing the pthread_sigmask call with > }> sigprocmask to see if it made any difference, which it didn't. > }Yes, at least with FreeBSD pthreads you have to either install a signal > }handler to catch these signals or to set the handler to SIG_IGN. When > }you set a threads signal mask, even if it is for all threads, you don't > }affect how signals are delivered to the process. The default action > }for SIGPIPE and SIGINT is to kill the process, so setting masks for > }threads doesn't affect this. > > I figured it was just using the default action for these signals. So, am > I mistaken in thinking that SIG_BLOCK was supposed to ignore those signals > or is this a pthreads bug on FreeBSD? Or just an "undefined" behaviour > and a pthreads gotcha? It's worth noting that even with pthreads on Solaris > I get the behaviour I was expecting (ie the signals are ignored) using > either pthread_sigmask or sigprocmask. It's not clear to me that using pthread_sigmask should change the default behaviour that signals have on the process. Thread signal masks seem to be independent of installed signal handlers and default actions that signals have on the process. > Also, is it documented anywhere which signals will behave like this? It > seems like it would be all of them, as if the process still has an inherent > signal mask independent of the threads running, thus requiring signal > handlers to be installed for them. Hmm, it's a lot more verbose calling > sigaction for every signal rather than a single pthread_sigmask call. > I guess that's why we have for loops. See sigaction(2). From your other email: > Doh! You can specify a set of signals with sigaction. Sorry about that. Nope, you can only install a handler for one signal at a time. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10202050010120.3489-100000>