Results 1 to 1 of 1
Thread: linux threads temination
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Jan 2009
linux threads temination
i am writing simple application where in the main process i will create two more threads using pthread_create() function. threads as well as main process will be in running contiously in infinite loops.main process and threads communicate using the named pipes.
if i kill main process explicitly by pressing ctrl+c i want to terminate all my threads and close all pipes opened. so to get that in the mian process i had a signal handler to catch terminate and ctrl+c signals.In the handler function i am sending pthread_cancel() to two threads i have created.in each thread i had set cancel state as asynchrounous and wrote the cleanup fuction where it will close the pipes file descriptors. is this the correct way to terminate the threads?how to write the cleanup for threads?
one more thing how to handle if one of the got killed threads explicitly?
how can write a signal handler for threads?
any examples on multithreaded linux programming will be appreciated....