Skip to content

move the remaining taskkill and sysctl call-outs to in-process C++ helpers #19285

Description

@kevinushey

#19233 moved the rig registry work and a process-liveness probe from PowerShell and tasklist to in-process C++ routines registered from SessionRUtil.cpp (.rs.isProcessRunning, .rs.registryGetValue/SetValue/DeleteValue). A survey of the remaining shell call-outs in the session turned up two more that could reasonably follow the same pattern, in a separate PR:

  • Stopping a Quarto job on Windows (src/cpp/session/modules/quarto/SessionQuartoJob.hpp, stop()) runs taskkill /F /T /PID <pid> through runCommand. Core already has getSubprocesses() on Windows and terminateProcess(), so a native terminateProcessTree(pid) in core::system would replace the shell and give a proper Error instead of parsed stderr.
  • The Apple Silicon check in SessionRig.R (.rs.rig.machineArchitecture, around line 110) shells out to /usr/sbin/sysctl -n hw.optional.arm64 to tell an x86_64 R running under Rosetta from a real Intel Mac. Core already has core::system::isAppleSilicon() (sysctlbyname); exposing it as a .Call routine makes the shell call-out go away.

Lower value, noted for completeness: SessionConnectionsInstaller.R runs REG ADD/REG DELETE against HKLM with /reg:32|64 before falling back to a .reg file opened in Explorer for the UAC prompt. The first attempt could use the registry routines from #19233 if they grew a WOW64 view flag, but the elevated fallback has to stay a separate process, so the gain is modest.

Everything else found (launchctl, rig, R CMD config, python/conda probes, pandoc, zip, odbcinst, brew, curl, open/nautilus, the desktop's fc-list) runs an external tool for its own sake or has no public API (launchd's setenv/getenv), and stays as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions