Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to keep descendant processes running after aftman closes #39

Open
Corecii opened this issue Nov 15, 2022 · 0 comments
Open

Ability to keep descendant processes running after aftman closes #39

Corecii opened this issue Nov 15, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Corecii
Copy link

Corecii commented Nov 15, 2022

The way Aftman puts processes into a job on Windows disallows all descendant processes from running after Aftman closes unless you do some really hacky stuff.

It is possible to allow job processes to break away from jobs without hacks: set the JOB_OBJECT_LIMIT_BREAKAWAY_OK limit on the job, then the child processes can break away if spawned with CREATE_BREAKAWAY_FROM_JOB.

This is almost straightforward: Rust already has a mechanism for setting creation flags like CREATE_BREAKAWAY_FROM_JOB. There's no existing API for setting job limits like JOB_OBJECT_LIMIT_BREAKAWAY_OK though, even in the command_group crate. The correct sequence for setting this limit looks like: create the job, set the limit, spawn the descendant processes. I feel like this would be a simple change to the command_group crate to support (or alternatively, a simple change to run the same code in Aftman instead).


I particularly need this for spawning Roblox Studio. Without this (or workarounds), Studio is closed as soon as the spawner is done. We are using this for a tool that downloads a copy of production and opens it as a local file to avoid mistakes that can happen when production is actually open.

This would also be applicable for any other launching-of-a-gui utility command.


As a workaround, the WMI Win32_Process.Create method just so happens to ignore jobs. I was having a lot of trouble calling this from Rust, so I ended up having Rust run a powershell snippet which spawns the process. How hacky!

To open a rbxl file, we do the following:

    powershell_script::run(&format!(
        r#"([WMICLASS]"win32_process").Create('explorer "{}"')"#,
        path.as_os_str().to_string_lossy()
    ))
@LPGhatguy LPGhatguy added the enhancement New feature or request label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants