linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Lee <live4thee@gmail.com>
To: Glynn Clements <glynn@gclements.plus.com>
Cc: "Michał Nazarewicz" <m.nazarewicz@samsung.com>,
	"Ardhan Madras" <nightdecoder@gmail.com>,
	linux-c-programming@vger.kernel.org
Subject: Re: Help on pipe
Date: Sat, 11 Jul 2009 11:41:41 +0800	[thread overview]
Message-ID: <8f62e1cd0907102041y454ac0dnfe98a25467964634@mail.gmail.com> (raw)
In-Reply-To: <19031.32022.804076.200185@cerise.gclements.plus.com>

2009/7/11 Glynn Clements <glynn@gclements.plus.com>:
>
> 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@gclements.plus.com>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-07-11  3:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10  6:22 Help on pipe Ardhan Madras
2009-07-10  7:06 ` Michał Nazarewicz
2009-07-10  7:34   ` Ardhan Madras
2009-07-10 17:40   ` Glynn Clements
2009-07-11  3:41     ` David Lee [this message]
2009-07-13  6:45     ` Michał Nazarewicz
2009-07-10  7:27 ` David Lee
  -- strict thread matches above, loose matches on Subject: below --
2009-07-10 18:21 Ardhan Madras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f62e1cd0907102041y454ac0dnfe98a25467964634@mail.gmail.com \
    --to=live4thee@gmail.com \
    --cc=glynn@gclements.plus.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=m.nazarewicz@samsung.com \
    --cc=nightdecoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).