摘要: 管道一般用与父子进程之间通信,下面是一个简单的父子进程通信事例:#include <unistd.h>#include <stdio.h>int main(){ int fd[2]; //管道入口fd[0]为读,fd[1]为写入口 char r_buf[100]; char w_buf[20]= "hello word!"; pid_t pid; if(pipe(fd) < 0) //新建管道 { printf("pipe error!\n"); exit(1); } if((pid = fork()) < 0) { 阅读全文
posted @ 2012-03-30 16:50 java简单例子 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 直接看代码#include <unistd.h>#include <stdio.h>#include <signal.h>void myfunc(){ printf("myfunc\n"); exit(0); //如果没有此句,程序在主函数中继续运行,输出never run}int main(){ unsigned int i; int time; alarm(9); sleep(2); time = alarm(0); //闹钟取消,返回剩余时间,每次只能有一个闹钟生效 printf("dd%d\n",time); 阅读全文
posted @ 2012-03-30 16:40 java简单例子 阅读(350) 评论(0) 推荐(0) 编辑