]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
When script(1) reads EOF from input it starts spinning on zero-byte
authortrociny <trociny@FreeBSD.org>
Tue, 27 Sep 2011 18:14:04 +0000 (18:14 +0000)
committertrociny <trociny@FreeBSD.org>
Tue, 27 Sep 2011 18:14:04 +0000 (18:14 +0000)
commit49d59b07385eea8e7512006f40a73580d4cef33a
tree72bc761ace1637d1fb035fc7bf1a0ab4c9fe17d8
parent43a4fd1bbd77bcc9aa1d36d874dcf151b4f08554
When script(1) reads EOF from input it starts spinning on zero-byte
reads eating 100% CPU. Fix this by skipping select on STDIN after
reading EOF -- permanently if STDIN is not terminal and for one second
if it is.

Also after reading EOF from STDIN we have to pass it to the program
being scripted. The previous approach was to write zero bytes into the
pseudo-terminal. This does not work because zero-byte write does not
have any effect on read. Fix this by sending VEOF instead.

Submitted by: Ronald Klop <ronald-freebsd8@klop.yi.org>
Discussed with: kib, Chris Torek <chris.torek@gmail.com>
Approved by: kib
MFC after: 1 week
usr.bin/script/script.1
usr.bin/script/script.c