kevin.cianfarini
07/04/2023, 12:53 AMio_uring
bindings for Kotlin/Native. In doing so I need a worker thread that does a blocking operation to poll for completion events from the linux kernel. I need a mechanism to cancel this blocking operation, especially because runInterruptible
doesn't exist in any form on native. To do this I've had to jump through a few hoops. I grab the underlying thread ID via pthread_self
and then register a coroutine which invokes pthread_kill(SIGINT)
when that coroutine is cancelled.
Here's where things get weird.
Originally I set up a signal handler via the libc signal
API and invoked pthread_exit
. This crashed the Kotlin/Native runtime. While debugging I commented that out and everything just...worked? The blocking operation from io_uring
started magically returning EINTR
meaning it was interrupted successfully despite my registered signal handler intercepting and suppressing the signal.
Does that sound plausible? Here's the PR with a more thorough explanation if anyone is interested.ephemient
07/04/2023, 2:03 AMephemient
07/04/2023, 2:04 AMephemient
07/04/2023, 2:05 AMkevin.cianfarini
07/04/2023, 2:05 AMSIGINT
was signaled if I've intercepted it and suppressed itkevin.cianfarini
07/04/2023, 2:05 AMkevin.cianfarini
07/04/2023, 2:05 AMephemient
07/04/2023, 2:05 AMkevin.cianfarini
07/04/2023, 2:06 AMkevin.cianfarini
07/04/2023, 2:06 AMephemient
07/04/2023, 2:06 AMephemient
07/04/2023, 2:07 AMkevin.cianfarini
07/04/2023, 2:07 AMephemient
07/04/2023, 2:09 AMephemient
07/04/2023, 2:10 AMkevin.cianfarini
07/04/2023, 2:11 AMkevin.cianfarini
07/04/2023, 2:11 AMephemient
07/04/2023, 2:13 AMephemient
07/04/2023, 2:14 AMkevin.cianfarini
07/04/2023, 2:18 AMkevin.cianfarini
07/04/2023, 2:18 AMkevin.cianfarini
07/04/2023, 2:18 AMephemient
07/04/2023, 3:05 AMephemient
07/04/2023, 3:05 AMephemient
07/04/2023, 3:06 AMkevin.cianfarini
07/04/2023, 5:23 PMkevin.cianfarini
07/27/2023, 1:13 AM