From: Richard M. <men...@hi...> - 2006-01-06 05:46:46
|
From: "Brian Dessent" <br...@de...> > Mingw uses the Microsoft C library (MSVCRT). glibc is designed for > linux and has not (and probably never will be) ported to win32. If you > want posix emulation, you want Cygwin not Mingw, which does include > (some) support for mkfifo(). > Hi, did you ever try the Cygwin's fifo, it seems that, if you do not read from the fifo, you can only write only one byte to it. but it's not the same on linux. Could you give some help. ----------- Code, built on Cygwin: -------------------------- #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <string.h> int main(void) { mkfifo("./test.fifo", 0666); int fd = open("./test.fifo", O_RDWR | O_NDELAY); if (fd == -1) { printf("Cannot open ./test.fifo\n"); exit(1); } int r=0; char b[]="ABCD"; if ((r=write(fd, b, strlen(b))) > 0) { ///<=== NOTE: if b is "A" this line will return successfully with 1, but here the "write" pauses and will not return unless another process or thread read from the test.fifo printf("write %d bytes\n", r); } else { printf("write error\n"); } close(fd); unlink("./test.fifo"); return 0; } -----------------End of Code -------------------------- Thanks, -- Richard Meng Hisilicon Semiconductor Co., Ltd. |