Skip to content

Fix DETACHED_PROCESS in the example. - #66

Merged
passcod merged 1 commit into
watchexec:mainfrom
raldone01:fix/minor-readme-docs
Oct 19, 2026
Merged

passcod merged 1 commit into
watchexec:mainfrom
raldone01:fix/minor-readme-docs

Conversation

@raldone01

@raldone01 raldone01 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The example on the main README didn't compile for me.
The windows crate might have renamed this.

Also I read the docs but I am unsure about the following:

#[cfg(windows)]
{
  use windows::Win32::System::Threading::*;
  wrapped_cmd
    .wrap(CreationFlags(CREATE_NO_WINDOW | DETACHED_PROCESS))
    .wrap(JobObject);
}
#[cfg(unix)]
wrapped_cmd.wrap(ProcessGroup::leader());

let mut child = wrapped_cmd.spawn()?;

let _ = child.kill();

Are the above platform specific wraps enough to make child.kill kill all the children the command spawned? Do I need platform specific kill code to make use of the JobObject or the ProcessGroup? The docs aren't too clear about what/how I can interact with these after creation. Thanks.

@passcod

passcod commented Oct 19, 2026

Copy link
Copy Markdown
Member

Are the above platform specific wraps enough to make child.kill kill all the children the command spawned?

Yes, except if the childs explicitly take themselves out of the process group or job object.

@passcod
passcod merged commit b0e2d0c into watchexec:main Oct 19, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants