Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
720abaa7
Commit
720abaa7
authored
Sep 22, 2015
by
Francis Dupont
Browse files
[4065] New threads got all signals blocked
parent
d24119e8
Changes
1
Show whitespace changes
Inline
Side-by-side
src/lib/util/threads/thread.cc
View file @
720abaa7
...
...
@@ -21,7 +21,9 @@
#include <cerrno>
#include <pthread.h>
#include <signal.h>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
using
std
::
string
;
...
...
@@ -33,6 +35,30 @@ namespace isc {
namespace
util
{
namespace
thread
{
namespace
{
// Signal blocker class.
class
Blocker
:
boost
::
noncopyable
{
public:
// Constructor blocks all signals
Blocker
()
{
sigset_t
new_mask
;
sigfillset
(
&
new_mask
);
pthread_sigmask
(
SIG_BLOCK
,
&
new_mask
,
&
old_mask_
);
}
// Destructor restores the previous signal mask
~
Blocker
()
{
pthread_sigmask
(
SIG_SETMASK
,
&
old_mask_
,
0
);
}
private:
// The previous signal mask
sigset_t
old_mask_
;
};
}
// The implementation of the Thread class.
//
// This internal state is not deleted until the thread terminates and is either
...
...
@@ -105,6 +131,7 @@ Thread::Thread(const boost::function<void ()>& main) :
impl_
(
NULL
)
{
auto_ptr
<
Impl
>
impl
(
new
Impl
(
main
));
Blocker
blocker
;
const
int
result
=
pthread_create
(
&
impl
->
tid_
,
NULL
,
&
Impl
::
run
,
impl
.
get
());
// Any error here?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment