From: Karel Zak <kzak@redhat.com>
To: Phillip Susi <psusi@ubuntu.com>
Cc: util-linux@vger.kernel.org
Subject: Re: script input redirection / eof handling
Date: Tue, 3 Dec 2013 13:55:21 +0100 [thread overview]
Message-ID: <20131203125521.GL5572@x2.net.home> (raw)
In-Reply-To: <20131202232513.GK5572@x2.net.home>
On Tue, Dec 03, 2013 at 12:25:13AM +0100, Karel Zak wrote:
> On Mon, Dec 02, 2013 at 01:06:05PM -0500, Phillip Susi wrote:
> > That only works if the program on the other end knows what "exit"
> > means, which is basically only true if it's a shell. Surely there
> > must be a proper way to signal EOF over a pty? Can you use shutdown()
> > on a pty?
>
> Oh, now it reminds me... in include/ttyutils.h we have macros to
> generate tty control chars, for example ^C
>
> char eof = DEF_EOF;
>
> if (write(master, &eof, 1) < 0) {
> warn (_("write failed"));
> fail();
> }
> pause();
>
> is what we need.
It was more tricky than I have originally expected, but it seems it
works. (It seems that it is not enough to send EOF, you have to be
sure that someone already listens on slave side.)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2013-12-03 12:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 14:21 script input redirection / eof handling Phillip Susi
2013-12-02 12:36 ` Karel Zak
2013-12-02 12:54 ` Karel Zak
2013-12-02 14:45 ` Phillip Susi
2013-12-02 17:02 ` Karel Zak
2013-12-02 18:06 ` Phillip Susi
2013-12-02 22:36 ` Karel Zak
2013-12-02 23:25 ` Karel Zak
2013-12-03 12:55 ` Karel Zak [this message]
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=20131203125521.GL5572@x2.net.home \
--to=kzak@redhat.com \
--cc=psusi@ubuntu.com \
--cc=util-linux@vger.kernel.org \
/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