I have written a program in C and have compiled it using MinGW. When I try to run that program in Cygwin, it seems to behave normally (i.e. prints correct output etc.)

However, I'm trying to pipe output to a program so that I can parse information from the program's output. However, the piping does not seem to be working in that I am not getting any input into the second program.

I have confirmed this by using the following commands:

This command seems to work fine:

./prog 

Performing this command returns nothing:

./prog | cat

This command verifies the first:

./prog | wc

Which returns:

0 0 0

I know that the script (including the piping from the program) works perfectly fine in an all Linux environment.

Does anyone have any idea for why the piping isn't working in Cygwin? Thanks!

link|improve this question
Do you get the same behaviour piping it to more or redirecting stdout to an actual file? – Breakthrough Jul 8 '11 at 16:40
@Breakthrough Yes. Outputting to a file "./prog &> output.txt" or "./prog > output.txt" yields an empty output.txt – KLee1 Jul 8 '11 at 16:45
a few questions: are you printing to stdout? are you printing the right end of line character for windows (\r\n)? – Pablo Castellazzi Jul 8 '11 at 21:17
@Pablo Castellazzi I am printing to stdout (just using printf), but am using "\n" instead of "\r\n." I don't think that should change the fact that I'm not getting any output at al, right? I will try changing the line endings to \r\n and let you know. – KLee1 Jul 8 '11 at 21:23
I just wrote a little C app that uses printf and was able to pipe to wc and less and such. What version of cygwin are you running? – Robb Jul 8 '11 at 22:15
show 3 more comments
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.