News for hackers. Stuff that matters.
Re:Tokio and Prctl = Nasty Bug by cryptonector on Tuesday February 25, 2025 @11:50AM (#43174280)
Ah, yes, that's true. I'm so used to using pipes like this that I forgot. You're quite right. Though I'd still use something like a pipe rather than a condition variable, say, because on Unix and Linux systems you can't have an event loop handle events on file descriptors _and_ condition variables.
Re:Tokio and Prctl = Nasty Bug by cryptonector on Tuesday February 25, 2025 @03:02PM (#43176582)
And those are my favorite signalling mechanisms: async I/O and condition variables.
Re:Tokio and Prctl = Nasty Bug by fc417fc802 on Tuesday February 25, 2025 @10:58PM (#43180449)
I thought the optimization goal was latency on the parent thread so I had in mind a bare atomic_store_explicit with memory_order_relaxed. However you wouldn't care about latency in the first place if you weren't scaling this up and obviously scaling up requires additional infrastructure that I'm ignoring here.

That said the linked article is using spawn_blocking from tokio meaning you can just call vfork directly and return the result. No need to roll your own in this case.

> you can't have an event loop handle events on file descriptors _and_ condition variables

Since events crossing the kernel boundary aren't fast to begin with I prefer to use a secondary event loop for the sluggish stuff and feed the output to the lower latency one.