On Sat, Jun 30, 2012 at 05:17:36PM +0100, Iain Paton wrote: > Came across an unexpected feature with script today. Can't make my mind up if > it's a bug or not, but it certainly makes some things difficult. Sorry for delay... > Seems that there's an implicit assumption that stdin will always be a tty for > the script process - strace shows all sorts of -ENOTTY stuff when it's not. Yes, "script - make typescript of terminal sessions". It initializes a new pseudoterminal and makes connection between the current session and the new terminal. > I came up with the following that works for my use case, but maybe there's a > better way ? > > --- script.c.org 2011-08-29 09:31:19.000000000 +0100 > +++ script.c 2012-06-30 16:24:42.896997422 +0100 > @@ -295,18 +295,29 @@ > > fclose(fscript); > > - while (die == 0) { > - if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) { > - ssize_t wrt = write(master, ibuf, cc); > - if (wrt < 0) { > - warn (_("write failed")); > - fail(); > + if(isatty(STDIN_FILENO)) { > + > + while (die == 0) { > + if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) { > + ssize_t wrt = write(master, ibuf, cc); > + if (wrt < 0) { > + warn (_("write failed")); > + fail(); > + } > } > + else if (cc < 0 && errno == EINTR && resized) > + resized = 0; > + else > + break; > + } > + } else { > + > + while(die == 0) { > + > + fd_set fs; > + FD_ZERO(&fs); > + select(1, &fs, &fs, &fs, NULL); Hmm... what the others things like tcsetattr(), etc. Anyway, I'll try to play with the patch. It seems like interesting idea. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html