NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/49092: make(1): output ordering changes when stdout is a file or pipe



>Number:         49092
>Category:       toolchain
>Synopsis:       make(1): output is not properly flushed after a failure is 
>ignored
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 08 21:35:00 +0000 2014
>Originator:     Jarmo Jaakkola <jarmo.jaakkola%roskakori.fi@localhost>
>Release:        NetBSD 6.1.2_PATCH
>Organization:
>Environment:
System: NetBSD kotoisa.roskakori.fi 6.1.2_PATCH NetBSD 6.1.2_PATCH (KOTOISA) 
#5: Mon Jan 20 17:01:44 EET 2014 
jammuli%kotoisa.roskakori.fi@localhost:/usr/src/sys/arch/amd64/compile/KOTOISA 
amd64
Architecture: x86_64
Machine: amd64
>Description:
When make is invoked with -k, a message about an ignored command failure
is output only after output from the next command has been printed if
stdout is a file or a pipe.  I'd assume this occurs because stdout is
line buffered if it is associated with terminal and block buffered otherwise.
The message being newline terminated and printing fine on terminal certainly
suggests that.
>How-To-Repeat:
$ cat >Makefile <<EOF
all: first second
first:
        @echo 'Next line should be: "*** Error code 1 (continuing)"'
        @false
second:
        @echo "Next line should be: \"\`all' not remade because of errors.\""
EOF

$ make -k
Next line should be: "*** Error code 1 (continuing)"
*** Error code 1 (continuing)
Next line should be: "`all' not remade because of errors."
`all' not remade because of errors.

$ make -k >log; cat log
Next line should be: "*** Error code 1 (continuing)"
Next line should be: "`all' not remade because of errors."
*** Error code 1 (continuing)
`all' not remade because of errors.

$ make -k | cat
Next line should be: "*** Error code 1 (continuing)"
Next line should be: "`all' not remade because of errors."
*** Error code 1 (continuing)
`all' not remade because of errors.
>Fix:
If stdout is flushed after the error message, the output is in correct
order.  Would it make sense to explicitly set the buffering strategy
on stdout in case there are other problems like this?  Anyway, here's
where you would do the flush.

--- usr.bin/make/compat.c.old
+++ usr.bin/make/compat.c
@@ -475,6 +475,7 @@
                    status = 0;
                }
            }
+           fflush(stdout);
            break;
        } else {
            Fatal("error in wait: %d: %s", retstat, strerror(errno));



Home | Main Index | Thread Index | Old Index