[SOLVED] Named pipes - Problem with write() and read()
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am doing programming in C++, under LINUX.
I have two independent processes. I should provide communication using named pipe.
-creates FIFO using mkfifo - status = mkfifo(myFIFO, 0666)
-opens the pipe using open - fifo = open (myFIFO,O_RDONLY)
-reads from the pipe - num = read(fifo, temp, sizeof(temp))
-opens pipe - fifo = open(myFIFO, O_WRONLY);
-writes to the pipe - num = write(fifo, string, strlen(string));
I have noticed that the file descriptor returned for read process
and write process are 0. Also, after command write, I can see on my terminal, the string which should be written to the pipe. I don't know why it is shown on terminal... Also, the number of bytes that are written is 0...