How to stop Linux threads cleanly
Let’s say you’re writing a long running multi-threaded application, on Linux. Maybe it’s a database or a server of some sort. Let’s also imagine that you’re not running on some managed runtime (maybe the JVM, Go, or BEAM), but rather managing threads spawned using the clone syscall. Think of threads created in C with pthread_create, or using C++’s std::thread.1
Once you get into the business of starting threads, you’re probably also in the business of stopping them. However the former is much ea...
Read more at mazzo.li