之前一直通过pthread_kill向指定线程发送信号,但后来将系统调用system换成了如下的实现:
long ___system(const char *pcStr)
{
int status; int pid; char tmpstack[SYSTEM_STACKSIZE]; void **newstack; newstack = (void **)(void *)(ULONG) (SYSTEM_STACKSIZE + tmpstack); *--newstack = (void *)pcStr; pid = clone(__system_proc, newstack, CLONE_VM | CLONE_FS | SIGCHLD, (void *)pcStr); if (pid < 0) { printf("clone() failed! errno = %d[%s]\n", errno, strerror(errno)); return -1; } (void)waitpid(pid, &status, __WALL /*__WCLONE*/); return status;
}
现在调用pthread_kill一直提示错误"no such process", 换回系统调用system又恢复正常。
我把CLONE_VM标志去掉,运行也是正常的,难道CLONE_VM对线程由啥影响?