2009/7/11 Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>:
>
> Michał Nazarewicz wrote:
>
>> > waitpid(pid, &ret, 0);
>> > close(fds[1]);
>>
>> No need to close.
>
> There definitely is a need to close, but it should be fclose(stream)
> *before* the waitpid(). As David points out, sort won't terminate
> until it has finished reading its input.
>
> David Lee wrote:
>
>> The sort program is waiting for an EOF (^D).
>
> Ctrl-D isn't EOF unless you're reading from a terminal. The TTY driver
> "sends EOF" (i.e. causes read() to return a zero count) when you press
> Ctrl-D (by default) if the driver is in canonical mode. Ctrl-D doesn't
> have any significance in other contexts.
>
Definitely! Thanks for pointing out. :-)
And BTW, `strace' is a handy tool for diagnosing this kind of problems.
> --
> Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Thanks,
Li Qun
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Assembler]
[Git]
[Kernel List]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[Yosemite Campsites]
[Yosemite News]
[GCC Help]