tgkill
-
생성된 pthread를 중간에 종료시키자.(pthread_cancel)IT/Linux C 2012. 1. 12.
pthraed_create를 통해서 만들어진 thread는 중간에 종료시켜야 할 필요가 있을 때 pthread_cancel를 사용하여 실행중인 thread를 종료 시킬 수 있다. #include int pthread_cancel(pthread_t thread); 간단히 작성한 코드를 작성하여 strace한 결과를 보면, clone 함수를 통해서 thread를 만들고(thread id:2104) 나중에 pthread_cancel이 호출되는 부분에서 tgkill 함수에 thread id를 넘겨 줌으로써 해당 thread를 취소시킨다. 사실 취소라는 말 보다는 시그널을 전달하여 종료시킨다라고 할 수 있다. ... clone(child_stack=0xb782b494, flags=CLONE_VM|CLONE_FS|..