Skip to content

Fix tee pipe #66

Merged
merged 1 commit into from
Jun 28, 2019
Merged

Fix tee pipe #66

merged 1 commit into from
Jun 28, 2019

Conversation

wwwutz
Copy link
Contributor

@wwwutz wwwutz commented Jun 12, 2019

fix it!

when something inside the spawned build script switches to nonbuffered IO and creates very long lines ( > 64k ) the build will fail. solution: replace the tee pipe with /usr/bin/script.

@donald
Copy link
Contributor

donald commented Jun 12, 2019

btw: Node itself seems to be the misbehaving piece (of s...) which randomly changes stdout to O_NONBLOCK. Because of this insane behavior, other people even put Node behind a wrapper, e.g. see https://github.com/cockpit-project/cockpituous/commit/159a916710af40e8bda0c1487472f8834d6b6024 where some of the related Node issues are referenced.

Is Node used by its own build system? Wouldn't be surprised about that.

tools/build.sh Outdated Show resolved Hide resolved
@donald
Copy link
Contributor

donald commented Jun 12, 2019

Alas, script might help, but doesn't really fix the problem:

test.sh

#! /bin/sh
./set-stdout-nonblock
xxd /dev/urandom

with set-stdout-nonblock doing the obvious ( fcntl(1,F_SETFL,O_NONBLOCK); ). This terminates after some random time, depending on the speed of the terminal. This is true for ./test.sh for ./test.sh|tee test.log and for script -c ./test.sh test.log.

With script instead of | tee we might avoid to die immediately when something tries to write more than the 64kb pipebuffer with a single write(), but the whole thing is still in an unreliable state and might terminate at random points, after stdout is broken by one of the programs called.

when something inside the spawned build script switches to
nonbuffered IO and creates very long lines ( > 64k ) the build
will fail. solution: replace the tee pipe with /usr/bin/script.
@donald
Copy link
Contributor

donald commented Jun 13, 2019

< /dev/null would be good, because whatever runs in the build script might read from stdin, waiting forever or producing random results if stdin is undefined (typically on a terminal). On the other hand, there is a exec < /dev/null in most build scripts. But even with stdin redirected to something defined, behavior of scripts (e.g. complicated test units) may change, because stdout would now be to a pseudo-terminal instead of a pipe. Something we need to remember, if old scripts, which used to work, should fail.

Would it be an alternative to try a workaround in this specific build script which uses a buggy software version?

E.g. something like

# redirecting stdout/stderr to fast storage because of node O_NONBLOCK bug (references...)
L=/dev/shm/node.build.$$.log
(
    exec >$L 2>&1
    ... do whatever....
)
cat $L
rm $L

(untested)

@pmenzel
Copy link
Contributor

pmenzel commented Sep 18, 2019

Would stdbuf help?

stdbuf - Run COMMAND, with modified buffering operations for its standard streams.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants