Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Sep 2011 20:24:23 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Mikolaj Golub <trociny@freebsd.org>
Cc:        "freebsd-stable@freebsd.org" <freebsd-stable@freebsd.org>, cperciva@freebsd.org, Jeremy Chadwick <freebsd@jdc.parodius.com>, Ronald Klop <ronald-freebsd8@klop.yi.org>
Subject:   Re: /usr/bin/script eating 100% cpu with portupgrade and xargs
Message-ID:  <20110918172423.GB1511@deviant.kiev.zoral.com.ua>
In-Reply-To: <868vpmdq11.fsf@kopusha.home.net>
References:  <op.v1y8gdtf8527sy@pinky> <20110918045413.GA63773@DataIX.net> <20110918053901.GA31617@icarus.home.lan> <op.v1zrszht8527sy@pinky> <86d3eydsmf.fsf@kopusha.home.net> <op.v1z4ooot8527sy@pinky> <868vpmdq11.fsf@kopusha.home.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--v4PrGfol6wGsg/Ra
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Sep 18, 2011 at 02:54:34PM +0300, Mikolaj Golub wrote:
>=20
> On Sun, 18 Sep 2011 13:25:26 +0200 Ronald Klop wrote:
>=20
>  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?
>=20
> AFAIR, this trick with writing 0 to emulate EOF because we can't close th=
e fd
> -- we still want to read from it.  Poor shutdown(2) for non-socket :-).
>=20
> Colin might tell more...

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

--v4PrGfol6wGsg/Ra
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)

iEYEARECAAYFAk52KUYACgkQC3+MBN1Mb4gI1wCcDM9mGLAyKEoecxKLXvLiqDTC
xrgAoM28QBmnM88nSDvXOKPjkCRh78j0
=e/jT
-----END PGP SIGNATURE-----

--v4PrGfol6wGsg/Ra--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110918172423.GB1511>