Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Jun 2016 22:12:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 210543] tip & cu busyloop when stdin is /dev/null
Message-ID:  <bug-210543-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D210543

            Bug ID: 210543
           Summary: tip & cu busyloop when stdin is /dev/null
           Product: Base System
           Version: 10.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: heikki@suonsivu.net

This is likely present in 10.2 and earlier.

tip/cu busyloops when stdin is redirected to /dev/null.  Using cu this way =
is a
simple way of logging data from serial ports, so this is not completely
uncommon thing to do.

The problem seems to be that this has never been written in, just a comment
which says:

"XXX does not check for EOF"

tipin function is not intended to exit, however, by a quick glance, it does=
 not
seem to be that there is any harm done doing so.  As there is no input for
commands, the tipout will not exit until killed or until it encounters some
sort of error, so simply exiting from tipin seems workable solution.  It wi=
ll
simply return to main function and exit normally, and the tipout will conti=
nue
to run.  The other alternative could be waiting for tipout, but I have not
figured out any reason to do that, as the input process is useless without
input.

A quick patch:

--- tip.c.orig  2015-08-12 17:22:33.000000000 +0300
+++ tip.c       2016-06-25 00:49:36.812976000 +0300
@@ -400,8 +400,11 @@
        }

        while (1) {
-               gch =3D getchar()&STRIP_PAR;
-               /* XXX does not check for EOF */
+               gch =3D getchar();
+               if (gch =3D=3D EOF)
+                       break;
+
+               gch =3D gch&STRIP_PAR;
                if ((gch =3D=3D character(value(ESCAPE))) && bol) {
                        if (!noesc) {
                                if (!(gch =3D escape()))

--=20
You are receiving this mail because:
You are the assignee for the bug.=



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