News for hackers. Stuff that matters.
Re:How to stop Linux threads cleanly by ta8645 on Monday January 08, 2024 @10:14AM (#38913081)
That contradicts the assertion made in the article:

    Well, since thread cancellation is implemented using exceptions, and
    thread cancellation can happen in arbitrary places, we’re always liable
    to a cancellation happening in a noexcept block, which is undefined
    behavior, and which in practice will cause your program to crash.

    So since C++11, and especially since C++14 where destructors are marked
    as noexcept by default, thread cancellation is essentially useless in C++
Re:How to stop Linux threads cleanly by otabdeveloper4 on Monday January 08, 2024 @02:59PM (#38917254)
The article is kinda useless, to be honest. Seems to be some sort of advanced blog spam and not somebody speaking from real experience.

Anyways, pthread_cancel can be of two types - asynchronous or deferred. Deferred is when cancellation happens only during a system call. It's the default and what you want. (You don't want the asynchronous mode.)

Under the hood thread cancellation is a C++ exception, so you still get RAII, etc.