Re: Help on pipe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
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

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux