Re: script input redirection / eof handling

Karel Zak
2013-12-03T12:55:25Z

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