jluliuchao的嵌入式博客
jluliuchao
全部博文(33)
2010年(1)
2009年(32)
larrywhe
zzbok
wibnmo
zhouwei5
alterlee
fuwang54
koko0112
文山科技
Love_章c
分类: LINUX
2009-11-11 16:17:41
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> int main(void) { char buf[80]; int fd; unlink( "zieckey_fifo" ); mkfifo( "zieckey_fifo", 0777 ); if ( fork() > 0 ) { char s[] = "Hello!\n"; fd = open( "zieckey_fifo", O_WRONLY ); write( fd, s, sizeof(s) ); //close( fd ); } else { fd = open( "zieckey_fifo", O_RDONLY ); read( fd, buf, sizeof(buf) ); printf("The message from the pipe is:%s\n", buf ); //close( fd ); } return 0; }
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <errno.h> int main( int argc, char **argv ) { mode_t mode = 0666; if ( argc !=2 ) { printf( "Usage:[%s] fifo_filename\n", argv[0] ); return -1; } if (mkfifo( argv[1], mode)<0 ) { perror( "mkfifo"); return -1; } return 0; }
上一篇:Linux系统线程同步:互斥量(mutex)
下一篇:全面的framebuffer详解
登录 注册