no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / config / run-and-prefix.py
blobaf27e6743bca5c2ce0d69632d0547dfd63a1ba4b
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 # This script runs a process and prefixes its output with.
7 # Usage: run-and-prefix.py prefix command arg0 argv1...
9 import os
10 import subprocess
11 import sys
13 sys.stdout = os.fdopen(sys.stdout.fileno(), "wb", 0)
14 sys.stderr = os.fdopen(sys.stderr.fileno(), "wb", 0)
16 prefix = sys.argv[1].encode("utf-8")
17 args = sys.argv[2:]
19 p = subprocess.Popen(
20 args,
21 bufsize=0,
22 stdout=subprocess.PIPE,
23 stderr=subprocess.STDOUT,
24 stdin=sys.stdin.fileno(),
25 close_fds=False,
28 while True:
29 data = p.stdout.readline()
31 if data == b"":
32 break
34 sys.stdout.write(b"%s> %s" % (prefix, data))
36 sys.exit(p.wait())