forked from lix-project/lix
Use pthread_cancel instead of a signal
Signal handlers are process-wide, so sending SIGINT to the monitor thread will cause the normal SIGINT handler to run. This sets the isInterrupted flag, which is not what we want. So use pthread_cancel instead.
This commit is contained in:
parent
aa1560ca07
commit
0fae20c362
|
@ -24,10 +24,7 @@ public:
|
||||||
struct pollfd fds[1];
|
struct pollfd fds[1];
|
||||||
fds[0].fd = fd;
|
fds[0].fd = fd;
|
||||||
fds[0].events = 0;
|
fds[0].events = 0;
|
||||||
if (poll(fds, 1, -1) == -1) {
|
if (poll(fds, 1, -1) == -1) abort(); // can't happen
|
||||||
if (errno != EINTR) abort(); // can't happen
|
|
||||||
return; // destructor is asking us to exit
|
|
||||||
}
|
|
||||||
assert(fds[0].revents & POLLHUP);
|
assert(fds[0].revents & POLLHUP);
|
||||||
/* We got POLLHUP, so send an INT signal to the main thread. */
|
/* We got POLLHUP, so send an INT signal to the main thread. */
|
||||||
kill(getpid(), SIGINT);
|
kill(getpid(), SIGINT);
|
||||||
|
@ -36,7 +33,7 @@ public:
|
||||||
|
|
||||||
~MonitorFdHup()
|
~MonitorFdHup()
|
||||||
{
|
{
|
||||||
pthread_kill(thread.native_handle(), SIGINT);
|
pthread_cancel(thread.native_handle());
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue