Skip to content

Commit

Permalink
mdevenv: exec directly into the program to run
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eli-schwartz committed Nov 17, 2024
1 parent 6f67b10 commit 1985ad1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mesonbuild/mdevenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}')

0 comments on commit 1985ad1

Please sign in to comment.