-
Notifications
You must be signed in to change notification settings - Fork 121
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
For some executables, cntr-c will leave zombie processes #374
Comments
Hi, The task is just a # ...
[tasks.mzoon]
description = "Run MZoon"
command = "cargo"
args = ["run", "--manifest-path", "../../crates/mzoon/Cargo.toml", "${@}"] The first idea how to resolve it - add the [tasks.mzoon]
ignore_signals = ["all"] # <----
command = "cargo"
args = ["run", "--manifest-path", "../../crates/mzoon/Cargo.toml", "${@}"] Then |
@MartinKavik thanks for the feedback. is there any signal you are getting that parent process died in your sub process? i guess the ctrlc you are not getting but i wonder whats there that prevents the process from being killed when the parent dies as well and how i can force kill those. |
I'm not sure if it'll answer your question, but: I've made a simple experiment - added /// Runs the requested command and return its output.
pub(crate) fn run_command_get_output(
command_string: &str,
args: &Option<Vec<String>>,
capture_output: bool,
) -> io::Result<Output> {
// --- NEW ---
ctrlc::set_handler(move || {
info!("Ctrl-C handled!");
}).expect("Error setting Ctrl-C handler");
// --- // ---
debug!("Execute Command: {}", &command_string);
// ... Then I executed (compare with the image in the previous comment #374 (comment)) As you can see, all running parts - cargo-make task, mzoon (Rust CLI app) and the server (based on Actix) - gracefully finished. So my observed understanding is that all processes and sub-processes receive
I don't know how it works on Windows but you can still press I think an interesting (and maybe a bit standard (?)) approach is to try to gracefully shutdown all involved processes on the first So I think/hope the "double Ctrl+C signal" described above would solve both problems with zombie/finishing processes. Perhaps there are some disadvantages but I can't see them now. |
@MartinKavik very interesting. maybe if we modify what you did to
if it does solve it, I would really appreciate a PR :) |
A cargo make task has to explicitly kill its children - without killing we just add a delay to the current cargo make behavior I think. I would start with double ctrl+c + print "shutting down..." message as you suggested and eventually add opt-in timeout in the future if needed. What do you think? |
I like the opt-in idea. [tasks.mytask]
command = "problem"
execution_hints = { "pass_break_signal" = true } not nice... but it could give a workaround to the issue which is pretty rare without breaking lots of other stuff. |
@MartinKavik I looked at that crate.
|
This is now officially released |
Hi @sagiegurari I just found that But it doesn't mention on README.md and https://sagiegurari.github.io/cargo-make/ and whatever called this: The comments above is the only one I can find that mention 'execution hints'
It would be great included in the user documentation. Plus, I found that log said execution_hints is unknown key:
but it actually works. the existance of execution_hints make a defferent behavior. how could it be? To help you understand here is my Makefile.toml: [config]
default_to_workspace = false
[tasks.techdocs]
description = "Backstage 의 techdocs 로 docs/ 아래 md 파일을 렌더링 합니다."
category = "Documentation"
command = "npx"
args = ["@techdocs/cli", "serve"]
[tasks.svelte-dev]
cwd = "moneycircuit-svelte"
command = "npm"
args = ["run", "dev"]
[tasks.rust-dev]
command = "cargo"
args = ["run", "-p", "moneycircuit"]
[tasks.dev]
description = "spwan all development relative process."
# https://github.com/sagiegurari/cargo-make/issues/374#issuecomment-1103619644
execution_hints = { "pass_break_signal" = true } # if without it, Ctrl+C left over child process. it cause a error on next run.
run_task = { name = ["techdocs", "rust-dev", "svelte-dev"], parallel = true } |
@rino0601 execution hints are not documented because it doesn't exist :) |
This is in to continue #355 since original issue was resolved, but additional flow reported by @mogenson was not and requires different handling.
There is a hacky workaround to use script executable for it in the meantime.
repro can be seen in https://github.com/mogenson/cargo-make-ctrl-c.git
The text was updated successfully, but these errors were encountered: