I'm creating an application for Linux Desktop that uses the standard input as a communications medium. It needs to work also when stdin is redirected from a file or a named pipe. To be more specific, the project is a tool for testing another app so I need to integrate it with other command line tools.
I'm currently using QSocketNotifier to detect when there is input and QFile is used to open stdin for reading.
While waiting for input I still need to keep the event loop running so I cannot use waitForReadyRead().
My approach works pretty well with no redirection and the case where the input comes from a file. If there is a pipe in between the expected behavior is that when something it written to the pipe, the app reads and processes the input and waits for further input. However, after the first input has been read, the socket notifier keeps emitting activated() signal even though there is no data to be read.
For some reason QFile::readyRead doesn't work at all. Is there a way this kind of thing could work?