|
| 1 | +#!/usr/bin/python2 |
| 2 | + |
| 3 | +# Copyright (C) 2013 Red Hat, Inc. |
| 4 | +# |
| 5 | +# Cockpit is free software; you can redistribute it and/or modify it |
| 6 | +# under the terms of the GNU Lesser General Public License as published by |
| 7 | +# the Free Software Foundation; either version 2.1 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# Cockpit is distributed in the hope that it will be useful, but |
| 11 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | +# Lesser General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Lesser General Public License |
| 16 | +# along with Cockpit; If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +# |
| 19 | +# This is certified, A-grade, high quality turd polish. Node leaves |
| 20 | +# stdio file descriptors in non-blocking mode when exiting. This has |
| 21 | +# been reported, fixed, unfixed, ad nauseum. |
| 22 | +# |
| 23 | +# https://github.com/nodejs/node/issues/14752 |
| 24 | +# https://github.com/nodejs/node/pull/17737 |
| 25 | +# https://github.com/nodejs/node/pull/20592 |
| 26 | +# https://github.com/nodejs/node/pull/21257 |
| 27 | +# |
| 28 | +# It's starting to fester. |
| 29 | +# |
| 30 | + |
| 31 | +import fcntl |
| 32 | +import os |
| 33 | +import subprocess |
| 34 | +import sys |
| 35 | + |
| 36 | +assert "NODE_PATH" in os.environ |
| 37 | +proc = subprocess.Popen([ os.environ["NODE_PATH"] ] + sys.argv[1:]) |
| 38 | +proc.wait() |
| 39 | + |
| 40 | +map(lambda fd: fcntl.fcntl(fd, fcntl.F_SETFL, fcntl.fcntl(fd, fcntl.F_GETFL) &~ os.O_NONBLOCK), [0, 1, 2]) |
| 41 | +sys.exit(proc.returncode) |
0 commit comments