-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
007adfa
commit 361da1c
Showing
4 changed files
with
577 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
#include <QTextStream> | ||
#include <iostream> | ||
|
||
#include <unistd.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
QTextStream& qout() { | ||
static QTextStream stream {stdout}; | ||
return stream; | ||
} | ||
QTextStream& qerr() { | ||
static QTextStream stream {stderr}; | ||
return stream; | ||
} | ||
|
||
int main() | ||
{ | ||
constexpr char fifo_name[] = "/tmp/fifo_test"; | ||
|
||
qout() << "Waiting for writers\n"; | ||
std::cout << "Waiting for writers\n"; | ||
int fd = open(fifo_name, O_RDONLY); | ||
if (fd < 0) { | ||
qerr() << "Cannot open FIFO file\n"; | ||
std::cerr << "Cannot open FIFO file\n"; | ||
return fd; | ||
} | ||
|
||
const int length = 6; | ||
char data[length]; | ||
ssize_t red = read(fd, data, length); | ||
if (red < 0) { | ||
qerr() << "Error reading from FIFO\n"; | ||
std::cerr << "Error reading from FIFO\n"; | ||
return red; | ||
} | ||
|
||
qout() << "Red from FIFO: " << data << '\n'; | ||
std::cout << "Red from FIFO: " << data << '\n'; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.