blob: f86667f46a2934974bf3a40047abb06f959a56c5 [file] [log] [blame]
Leonardo Sandovald05adab2020-08-10 14:01:54 -05001#!/usr/bin/env python3
2#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8import subprocess
9
10def exec_prog(prog, args=[], out=None, out_text_mode=False):
11 # Build the command line to execute
12 cmd = [ prog ] + args
13
14 # Spawn process.
15 # Note: The standard error output is captured into the same file handle as
16 # for stdout.
17 process = subprocess.Popen(cmd, stdout=out, stderr=subprocess.STDOUT,
18 universal_newlines=out_text_mode, bufsize=0)
19 print("Spawned process with PID %u" % process.pid)
20 return process