From e57145a65fafb0855be27cfc906ef5b602899cf9 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 8 Nov 2024 16:18:57 -0500 Subject: [PATCH] mdevenv: exec directly into the program to run We don't need an extra process in the process tree (specifically the `meson devenv` process itself). Aside for the redundancy, it's actively problematic if you abort a program in the devenv by using CTRL+C, as meson itself will then emit a traceback (KeyboardInterrupt) which is quite ugly. (cherry picked from commit 1985ad19cb69f6db1d7e2e0c89fa6796782bfd43) --- mesonbuild/mdevenv.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py index 064cf5ed6f89..8c6ce2031d45 100644 --- a/mesonbuild/mdevenv.py +++ b/mesonbuild/mdevenv.py @@ -9,7 +9,7 @@ from pathlib import Path from . import build, minstall -from .mesonlib import (EnvironmentVariables, MesonException, is_windows, setup_vsenv, +from .mesonlib import (EnvironmentVariables, MesonException, join_args, is_windows, setup_vsenv, get_wine_shortpath, MachineChoice, relpath) from .options import OptionKey from . import mlog @@ -226,10 +226,9 @@ def run(options: argparse.Namespace) -> int: args[0] = abs_path or args[0] try: - return subprocess.call(args, close_fds=False, - env=devenv, - cwd=workdir) - except subprocess.CalledProcessError as e: - return e.returncode + os.chdir(workdir) + os.execvpe(args[0], args, env=devenv) except FileNotFoundError: raise MesonException(f'Command not found: {args[0]}') + except OSError as e: + raise MesonException(f'Command `{join_args(args)}` failed to execute: {e}')