Skip to content

Commit

Permalink
release: Don't let node mess up stdio
Browse files Browse the repository at this point in the history
Node leaves stdio file descriptors in non-blocking mode
when exiting. This has been reported, fixed, unfixed, ad nauseum.

nodejs/node#14752
nodejs/node#17737
nodejs/node#20592
nodejs/node#21257

Stolen from cockpit-project/cockpit@ef50d97cf4
  • Loading branch information
martinpitt committed Jul 12, 2018
1 parent 5732e22 commit 159a916
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ yum-utils \

ADD * /usr/local/bin/

# HACK: Working around Node.js screwing around with stdio
ENV NODE_PATH /usr/bin/node.real
RUN mv /usr/bin/node /usr/bin/node.real
ADD node-stdio-wrapper /usr/bin/node

VOLUME /home/user /build
WORKDIR /build
USER user
Expand Down
17 changes: 17 additions & 0 deletions release/node-stdio-wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# This is certified, A-grade, high quality turd polish. Node leaves
# stdio file descriptors in non-blocking mode when exiting. This has
# been reported, fixed, unfixed, ad nauseum.
#
# https://github.com/nodejs/node/issues/14752
# https://github.com/nodejs/node/pull/17737
# https://github.com/nodejs/node/pull/20592
# https://github.com/nodejs/node/pull/21257
#
# It's starting to fester.

OUT=$(/usr/bin/node.real "$@" 2>&1 </dev/null)
ret=$?
echo -n "$OUT"
exit $ret

0 comments on commit 159a916

Please sign in to comment.