您的位置:首页 > 运维架构 > Linux

linux_治理阻塞

2013-12-05 12:58 225 查看
sometimes linux thread can not stop, do like this:

#include<memory.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
pid_t pid;
char cmd[50];

if((pid=fork())==0){
printf("child process ---in ---->\n");
while(1)
{
printf("sleep 2s ..\n");
sleep(2);
}
printf("child process ---end ---->\n");
exit(0);
}else if(pid>0){
printf("father process ---in ---->\n");
printf("child process pid is %d\n",pid);
memset(cmd, 0 ,sizeof(cmd));
sprintf(cmd, "kill -9 %d", pid);
printf("%s\n",cmd);
system(cmd);
waitpid(pid,NULL,0);
printf("father process ---end ---->\n");
exit(0);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux thread