C++ program is hanging when invoking 'mkfifo' (Lustre FS)
I got an answer from the author https://github.com/alexdobin/STAR/issues/687
The program generated a shell script that was missing a shebang delcaration: this prevented the fifo stream from working.
mkfifo() error --- Error creating the named pipe.: File exists
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);
How do I perform a non-blocking fopen on a named pipe (mkfifo)?
You could open()
your pipe O_RDONLY | O_NONBLOCK
, and if you want the C stream, you can get it with fdopen()
. However, there might be a problem with the select()
- AFAIK, a pipe fd open for reading that has no writer is always prepared for reading, and read()
returns 0, so the select()
would fire indefinitely.
A kludgy way of overcoming this would be to open the pipe O_RDWR
; that is, have at least one writer (your C++ program). Which would solve your problem anyway.
Related Topics
How to Typedef a Function Pointer with the C++11 Using Syntax
Removing Watermark Out of an Image Using Opencv
Hooking Directx Endscene from an Injected Dll
Is Python Faster and Lighter Than C++
What Is Different Between Join() and Detach() for Multi Threading in C++
How to Embed Webkit into My C/C++/Win32 Application
What Is the Most Efficient Way to Display Decoded Video Frames in Qt
General Rules of Passing/Returning Reference of Array (Not Pointer) To/From a Function
Throw New Std::Exception VS Throw Std::Exception
How to Pass Command Line Arguments to a C Program
What Exactly Are C++ Definitions, Declarations and Assignments
Capturing a Time in Milliseconds