Reputation: 868
I am trying to run C++ application that works perfectly on Mac OS under Ubuntu. The problem is due to failure in opening a named pipe.
I used mkfifo
as follows:
pipe_name_ = std::string("/tmp/myfifo");
if (mkfifo(pipe_name_.c_str(), 0666) < 0) {
error_print("Cannot create a named pipe\n");
return -1;
}
if ((fd_ = open(pipe_name_.c_str(), O_RDONLY | O_CREAT, 0666)) < 0) {
error_print("Cannot open file description named %s %s\n",
pipe_name_.c_str(), strerror(errno));
return -1;
}
However, this prints into screen the bellow message that is for open()
:
Cannot open file description named /tmp/myfifo Invalid argument
My permissions status is as bellow:
$ls -la /tmp/myfifo
prw-r----- 1 hamidb nonconf 0 Jun 20 13:35 /tmp/myfifo
$umask
0027
I am wondering why it was working fine on Mac OS and not on Linux.
Upvotes: 0
Views: 1052
Reputation: 59987
I believe that you have the wrong flags for open
as you are not creating the file.
It should be
open(pipe_name_.c_str(), O_RDONLY)
Upvotes: 3