Skip to content

Commit

Permalink
host/python/uhd/imgbuilder/image_builder.py: Do not use os.system, as…
Browse files Browse the repository at this point in the history
… 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 <frederik.pfautsch@missinglinkelectronics.com>
  • Loading branch information
f14h committed Dec 17, 2024
1 parent e75629c commit f84563f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion host/python/uhd/rfnoc_utils/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def build(fpga_top_dir, device, build_dir, use_secure_netlist, **args):
os.chdir(fpga_top_dir)
make_cmd = f'{BASH_EXECUTABLE} -c "{make_cmd}"'
logging.info("Executing the following command: %s", make_cmd)
ret_val = os.system(make_cmd)
ret_val = subprocess.call(make_cmd, shell=True)
if ret_val == 0 and args.get("secure_core"):
patch_netlist_constraints(device, build_dir)
os.chdir(cwd)
Expand Down

0 comments on commit f84563f

Please sign in to comment.