[Bug 210543] tip & cu busyloop when stdin is /dev/null

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Jun 24 22:12:54 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210543

            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 at FreeBSD.org
          Reporter: heikki at 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 will
simply return to main function and exit normally, and the tipout will continue
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 = getchar()&STRIP_PAR;
-               /* XXX does not check for EOF */
+               gch = getchar();
+               if (gch == EOF)
+                       break;
+
+               gch = gch&STRIP_PAR;
                if ((gch == character(value(ESCAPE))) && bol) {
                        if (!noesc) {
                                if (!(gch = escape()))

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


More information about the freebsd-bugs mailing list