The mkfifo function takes 2 arguments, path and mode. But I don't know what is the format of the path that it uses. I am writing a small program to create a named pipe and as path in the mkfifo
. Using /home/username/Documents
for example, but it always returns -1 with the message Error creating the named pipe.: File exists
.
I have checked this dir a lot of times and there is no pipe inside it. So I am wondering what is the problem. The mode I use in mkfifo is either 0666 or 0777.
You gave mkfifo()
the name of an existing directory, thus the error. You must give it the name of a non-existing file, e.g.
mkfifo("/home/username/Documents/myfifo", 0600);