Skip to content

Commit

Permalink
python: use better argv[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Jan 13, 2025
1 parent 1ccad65 commit b75fc14
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/remage/cli.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
from __future__ import annotations

import shutil
import signal
import subprocess
import sys
from pathlib import Path

from .cpp_config import REMAGE_CPP_EXE_PATH


def _run_remage_cpp() -> int:
"""run the remage-cpp executable and return the exit code as seen in bash."""
# reuse our own argv[0] to have helpful help messages.
proc = subprocess.Popen(sys.argv, executable=REMAGE_CPP_EXE_PATH)
# but is is expanded (by the kernel?), so find out if we are in $PATH.
argv = list(sys.argv)
exe_name = Path(argv[0]).name
if shutil.which(exe_name) == sys.argv[0]:
argv[0] = exe_name
proc = subprocess.Popen(argv, executable=REMAGE_CPP_EXE_PATH)

# propagate signals to the C++ executable.
def new_signal_handler(sig: int, _):
Expand Down

0 comments on commit b75fc14

Please sign in to comment.