Hi,
I'm trying to write a program using named pipes, and I'm having trouble opening it. In another program I call this line:
mkfifo("./fife", 0777);
So my named pipe exists and I see it in my list of files. Then I run the program I included below, but I can not get past the open call. Any help would be appreciated for I can not find a lot of resources on this subject.
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <iostream>
#define MSGSIZE 14
void main() {
char *message = "Hello, world!";
int fd;
fd = open("fife", O_WRONLY);
// Can not get past this point!
cout << "fd: " << fd << endl;
if (write(fd, message, MSGSIZE) < 0)
cout << "error writing" << endl;
close(fd);
}