Skip to content

Commit 4276e82

Browse files
committed
host/python/uhd/imgbuilder/image_builder.py: Do not use os.system, as it encodes the return value
os.system's return value is the process's return value, but encoded in the wait format on Linux which means, that the result is multiplied by 256. Thus a return value of 1 of the executed command results in a ret_val of 256, an return value of 2 means 512, and so on. If this value is forwarded without further handling, and naively used as "normal" exit status, then the value overflows and always results in a 0 exit code. Instead of implementing a Windows/Linux dependant workaround, using subprocess instead of os.system is better anyway, as the usage of os.system is discouraged. Signed-off-by: Frederik Pfautsch <[email protected]>
1 parent e75629c commit 4276e82

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

host/python/uhd/rfnoc_utils/image_builder.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,12 @@ def build(fpga_top_dir, device, build_dir, use_secure_netlist, **args):
290290
logging.info(" * Build Output Directory: %s", build_output_dir)
291291
logging.info(" * Build IP Directory: %s", build_ip_dir)
292292
# Wrap it into a bash call:
293-
logging.debug("Temporarily changing working directory to %s", fpga_top_dir)
294-
os.chdir(fpga_top_dir)
295293
make_cmd = f'{BASH_EXECUTABLE} -c "{make_cmd}"'
296294
logging.info("Executing the following command: %s", make_cmd)
297-
ret_val = os.system(make_cmd)
295+
my_env = os.environ.copy()
296+
ret_val = subprocess.call(make_cmd, shell=True, env=my_env, cwd=fpga_top_dir)
298297
if ret_val == 0 and args.get("secure_core"):
299298
patch_netlist_constraints(device, build_dir)
300-
os.chdir(cwd)
301299
return ret_val
302300

303301

0 commit comments

Comments
 (0)