Reading from stdin till eof stuck when sending multiple commands
Hi,
i have a C application called "read_stdin" that looks like:
while (!feof(stdin) && !ferror(stdin))
{
iSize = fread(szBuffer, sizeof(char), sizeof(szBuffer), stdin);
if (iSize>0)
{
fwrite(szBuffer, sizeof(char), iSize, stdout);
}
}
when sending some commands by 'paste' to the terminal, which ends with EOF sometimes the application gets stuck.
e.g. paste the 3 following command:
./read_stdin
abcd def feg
(last line is ^D to terminate the input. doesn't work even with 'regular' char like after running: stty eof 'k')
Any Ideas?
Thanks,
Fredy
|