[fpc-pascal] pthread_detach

Marco van de Voort fpc at pascalprogramming.org
Sun Oct 30 12:55:25 CET 2022


On 30-10-2022 12:28, Hairy Pixels via fpc-pascal wrote:
> The POSIX thread library has a function called pthread_detach (https://man7.org/linux/man-pages/man3/pthread_detach.3.html). Do the RTL threads have anything comparable?

Yes. They call pthread_detach when ending, i.e. just before calling 
pthread_exit. So if you use normal threads, you already use that.

Similarly, pthread_join is a part of tthread.waitfor .  Have a look at 
rtl/unix/cthreads.pp for how the RTL threads map to pthreads on *nix 
systems.

> Honestly I don’t really understand why this is even needed because the threads seem to clean themselves up when they exit anyways but since it exists in pthreads I thought I was ask.

Maybe there are other uses of pthread_detach that don't immediately call 
_exit.  I'm not pthreads expert, so I can't help there.



More information about the fpc-pascal mailing list