ChinaUnix.net
相关文章推荐:

fifo文件 写阻塞

想实现这么一功能 文件若干分钟(可设置)以后,用新数据不断的挤掉最前面的数据。 我的想法是, 用附加的方式,那怎么删掉前面的数据呢? 不知道大家有没有什么想法 google了一下,管道可以实现这个功能? [ 本帖最后由 marco_hxj 于 2009-1-23 15:29 编辑 ]

by marco_hxj - C/C++ - 2009-02-02 09:22:44 阅读(2713) 回复(13)

相关讨论

先指定O_NONBLOCK以非阻塞的方式打开一个fifo, 然后使用fcntl清除它的O_NONBLOCK标志, 这样好象没有生效,再使用read时仍然是非阻塞的。 请哪位大哥指点一下,是不是fifo不支持fcntl的操作呢?

by Diff - C/C++ - 2004-11-09 11:10:04 阅读(694) 回复(0)

如果不用O_NONBLOCK的话,会不会一直阻塞在哪儿,那随后的判断是啥意思,阻塞了还能执行后面的语句吗〉 int writefd = open( pProCom->m_pSndPara->tempPipeName, O_WRONLY, 0 ); if( writefd == -1 ) { printf("open for write error"); }

by boldeagle - Linux环境编程 - 2007-12-15 20:21:03 阅读(6073) 回复(4)

今天看了有关fifo文件的介绍,如果有两个进程同时请求一个fifo文件,linux是怎么实现互斥的,怎么使不同进程的数据不至于交织在一起?

by wuyu1125 - Linux新手园地 - 2012-11-18 14:16:23 阅读(991) 回复(1)

在我测试的linux机器上,fifo的容量是64K。建了一个fifo(mkfifo,非阻塞方式)之后,write很多次直至满。此时去读一次fifo,理论上,读了一条记录出来,就会空出至少一条记录的空间,这时候我再尝试write的话,应该成功。 实际情况却不是这样的:假如在此前write的时候,每次比如入500字节的记录;当读取了一次之后,再尝试入依然失败。于是在一个loop中,再读一条,再尝试一次,如此连续8次,第9次才能够入成功。此前已经...

by 夜鸣剑 - C/C++ - 2011-10-04 21:18:49 阅读(3078) 回复(2)

我在freebsd7上 $mkfifo f1 $echo "KK">f1 然后shell阻塞到了这里,开另一个console,输入 $read t>f1效果是一样的。在阻塞的过程中,按下^C就会显示Interrupted system call 问题: fifo的操作总是阻塞和同步的吗,我是否可以向fifo里面入一点东西,过一段时间再从这个fifo里面读出呢? 或者说echo "KK">f1这个操作是否可以不被阻塞而是立刻结束? 谢谢!

by jeanlove - Shell - 2009-04-30 23:02:43 阅读(2108) 回复(8)

服务端:[code]#include #include #include #include #include #include #include #include #include void cat_fifo(int signo) { printf("catch SIGPIPE\n"); } int main(int argc , char *argv[]) { int fd; char buf[] = "hello server"; int n; int n1; signal(SIGPIPE, cat_fifo); ...

by chenjie901 - Linux环境编程 - 2012-10-14 14:38:55 阅读(1176) 回复(5)

本帖最后由 smalltom30 于 2012-12-12 14:41 编辑 1.用mkfifo生成fifo1文件 2.代码运行到open时,就挂住了,该怎么改呢?

by smalltom30 - C/C++ - 2012-12-04 10:22:58 阅读(1487) 回复(6)

本帖最后由 1ming0 于 2011-09-27 08:38 编辑 [code] #include #include #include #include #include #include #include #define FNAME "/tmp/daemon1.out" static FILE *fp; static int daemonize(void) { pid_t pid; int fd; fd = open("/dev/null", O_RDWR); if (fd<0) { syslog(LOG_WARNING, "open(\"/dev/null\"): %s", strerror(er...

by 1ming0 - Linux环境编程 - 2011-09-27 09:17:36 阅读(2284) 回复(4)

阻塞fifo的程序: read_fifo.c [code] #include #include #include #include #include #define fifo_PATH "/tmp/test_fifo" #define LEN 1000 int main(void) { int fd, n; char buf[LEN] ; if (mkfifo(fifo_PATH, 0600) < 0) { // 创建fifo if (errno != EEXIST) { perror("mkfifo"); exit(...

by grt8000 - C/C++ - 2006-07-04 20:30:00 阅读(3109) 回复(8)

在FB8上執行創建fifo管道文件時 出現以下錯誤,google了一把,也沒有結果,高手給解答一下![code][root@fse /home/workstation/programer/cprgm]# ./a.out cannot create fifoserver Preparing for reading bytes.... open: No such file or directory[/code]

by cgmeco - BSD - 2010-08-08 20:11:44 阅读(1976) 回复(5)