具有竞争条件的程序 | Unix进程控制
2012-11-16 21:09
246 查看
#include"apue.h"
static void charatatime(char *);
int main(void)
{pid_t pid;
if((pid=fork())<0){
err_sys("fork error");
}else if(pid==0){
charatatime("output fron child\n);
}else{
charatatime("output from parent\n);
}
exit(0);
}
static void charatatime(char *str)
{char *ptr;
int c;
setbuf(stdout,NULL);
for(ptr=str;(c=*ptr++)!=0;)
putc(c,stdout);
}
static void charatatime(char *);
int main(void)
{pid_t pid;
if((pid=fork())<0){
err_sys("fork error");
}else if(pid==0){
charatatime("output fron child\n);
}else{
charatatime("output from parent\n);
}
exit(0);
}
static void charatatime(char *str)
{char *ptr;
int c;
setbuf(stdout,NULL);
for(ptr=str;(c=*ptr++)!=0;)
putc(c,stdout);
}
相关文章推荐
- 避免竞争条件的程序 | Unix进程控制
- 8.9 进程控制_竞争条件
- 进程控制之竞争条件
- linux c编程:进程控制(二)_竞争条件
- unix进程控制
- 进程控制-进程程序替换(exec函数簇)
- 【Unix】进程控制
- Windows开发--控制程序运行单一进程
- Linux/UNIX进程控制(1)
- 编写一unix程序,防止僵尸进程的出现
- 通过 Mutex/Semaphore 实现程序进程实例的控制
- Linux/Unix进程控制(2)
- 程序流程的控制之条件分支(Delphi)
- Unix/Linux C++应用开发-C++控制结构"条件语句"
- unix_8_进程控制(一)
- unix环境高级编程----进程控制fock()函数
- UNIX进程控制
- Linux/Unix进程控制(3)
- UNIX/Linux-进程控制(实例入门篇)
- UNIX环境高级编程之第8章:进程控制