c - Writing string to pipe -
i trying send string pipe in unix. when go through line-by-line debugging process, call mkfifo() creates file in same directory source code. however, when reach open() call, debugger no longer able proceed. i'm not sure why unable access pipe file.
here's code in question:
#include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main() { int fd; char * myfifo = "myfifo"; /* create fifo (named pipe) */ mkfifo(myfifo, 0666); /* write "hi" fifo */ fd = open(myfifo, o_wronly); write(fd, "hi", sizeof("hi")); close(fd); /* remove fifo */ unlink(myfifo); return 0; }
any suggestions appreciated. thank you.
normally fifo has open @ both ends simultaneously before either side can proceed. since didn't mention reader, answer haven't got one, or haven't set yet. once do, open allowed proceed.
Comments
Post a Comment