pthread_kill 實驗
Thread as Process 在 Linux 底下,每個 thread 在排程時都會被當作 process,也都有個 pid。所以在 kill thread 的 pid 時,會在該 thread 起 signal handler。 Code #include <pthread.h> #include <unistd.h> #include <stdio.h> #include <signal
Thread as Process 在 Linux 底下,每個 thread 在排程時都會被當作 process,也都有個 pid。所以在 kill thread 的 pid 時,會在該 thread 起 signal handler。 Code #include <pthread.h> #include <unistd.h> #include <stdio.h> #include <signal
Manual pthread_cancel(3) - Linux manual page 根據 linux manual 所寫,pthread_cancel 基本上可以在一些可中斷的地方(POSIX 給了一個清單,大概是 IO 操作的時候)中斷 thread。 這時就好奇了:C++ 的 Destructor 會不會被觸發?這並沒有寫在文件上。 Code #include <pthread.h> #