Reputation: 571
I'm writing a simple character device driver for Linux with blocking read() and write().
What I want to do is to set them as cancellation points, so that calling a pthread_cancel on a thread suspended on these functions will cause it to terminate.
How is it possible to set them as cancellation points?
Thanks in advance.
Upvotes: 1
Views: 123
Reputation: 239071
If you're writing the kernel driver, all you need to do to make sure that read()
and write()
correctly function as cancellation points for userspace is to ensure that they return immediately if a signal is raised on the process while it's waiting in kernel space (either with a short item count or the EINTR
error).
This generally means using wait_event_interruptible()
followed by a check for if (signal_pending(current))
.
Upvotes: 2