/usr/bin/script eating 100% cpu with portupgrade and xargs

Mikolaj Golub trociny at freebsd.org
Sun Sep 18 20:58:04 UTC 2011


On Sun, 18 Sep 2011 20:24:23 +0300 Kostik Belousov wrote:

 KB> On Sun, Sep 18, 2011 at 02:54:34PM +0300, Mikolaj Golub wrote:
 >> 
 >> On Sun, 18 Sep 2011 13:25:26 +0200 Ronald Klop wrote:
 >> 
 >>  RK> It is a while since I programmed C, but why will writing 0 bytes give
 >>  RK> the reader an end-of-file? Shouldn't the fd be closed to indicate
 >>  RK> end-of-file?
 >> 
 >> AFAIR, this trick with writing 0 to emulate EOF because we can't close the fd
 >> -- we still want to read from it.  Poor shutdown(2) for non-socket :-).
 >> 
 >> Colin might tell more...

 KB> Please note that interpreting the receiving of 0 bytes on the terminal 
 KB> as EOF is only a convention. If done absolutely properly, script shall
 KB> not interpret zero-byte read as EOF. Might be, the reasonable thing to
 KB> do would be to only look at the stdin once in a second after receiving
 KB> zero-bytes, and switching it back to normal mode if something is read.

Ok. I see. Below is the patch that does something like this.

-- 
Mikolaj Golub

-------------- next part --------------
A non-text attachment was scrubbed...
Name: script.c.1.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20110918/641830c5/script.c.1.bin


More information about the freebsd-stable mailing list