A: 

I may be wrong, but does having a timeout of 0 for the select call makes sense? I would try to increase the timeout value.

Martin Cote
Doesn't change anything to increase it (tried up to 500 usecs)
+1  A: 

You have two if's; removing which one makes it work?

Doesn't fgets() wait for a newline, buffer full, or EOF before it returns? I don't see you writing a newline, "foo" doesn't fill the buffer, and since the stream isn't closed, does it see an EOF?

lavinio
The first if and yes, the write I've supplied here didn't reflect what I have in code, just changed that.
A: 

I remember there being a lot of argument about the semantics and operation of select() and a couple of replacements for it. You might look at those.

How is the stream you're reading being created/opened? Is it a buffered stream? Perhaps you get nothing because it's not been written to the stream until the writing process flushes it?

The other thing you might try is putting it on a thread with blocking I/O instead of polling.

Good luck with it

Jay
A: 

Turns out its not the QCoreApplication as I could now reproduce the problem twice with out. Seems like the problem is the fgets() that I'm using, replacing that with read() fixes it.

A: 

is the below inside the while loop, if not it should be.

FD_ZERO ( &fds );
FD_SET ( 0, &fds );

struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;

if the answer for my first question is yes, then please try this timeout

tv.tv_sec = 0;
tv.tv_usec = 1;

if the above doest work, try this

while(fgets(buf, sizeof ( buf ) - 1, stdin) !=NULL) { }

Warrior