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非阻塞的socket EAGAIN的错误处理
- linux非阻塞的socket EAGAIN的错误处理
- 嵌入式linux:阻塞与非阻塞驱动
- linux 下阻塞睡眠等待poll函数简单实现
- linux的同步,异步,阻塞,非阻塞
- 那年,一步一步学linux c ---sigprocmask 阻塞进程---sem_wait/sem_post
- linux下串口的阻塞和非阻塞操作
- linux网络编程:设置非阻塞socket收发数据
- Linux下同步模式、异步模式、阻塞调用、非阻塞调用
- linux嵌入式开发中,由串口日志中需要输入选择而导致的系统阻塞处理方法
- linux设备驱动之阻塞与非阻塞I/O
- Linux的阻塞與非阻塞
- Linux socket 阻塞与非阻塞,同步与异步、I/O模型
- 简述linux同步与异步、阻塞与非阻塞概念以及五种IO模型
- linux下socket connect 阻塞方式 阻塞时间控制
- linux文件设备与I/O:read/write函数与阻塞 Block
- Linux下socket设置为非阻塞方式和fcntl系统调用
- Linux下非阻塞connect
- linux文件设备与I/O:read/write函数 与 阻塞 Block
- [Linux线程]多线程的阻塞和退出