From 8d8dfa6d5c347cefe6e28ec251aed98f50900426 Mon Sep 17 00:00:00 2001 From: Daniel Peng Date: Wed, 22 Jan 2025 22:56:18 -0800 Subject: [PATCH] Add LIMIT_BREAKAWAY_OK as available flag --- src/limits.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/limits.rs b/src/limits.rs index d36f70f..c87c374 100644 --- a/src/limits.rs +++ b/src/limits.rs @@ -1,8 +1,9 @@ use windows::Win32::System::{ JobObjects::{ JOBOBJECT_EXTENDED_LIMIT_INFORMATION, JOB_OBJECT_LIMIT_AFFINITY, - JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOB_OBJECT_LIMIT_PRIORITY_CLASS, - JOB_OBJECT_LIMIT_SCHEDULING_CLASS, JOB_OBJECT_LIMIT_WORKINGSET, + JOB_OBJECT_LIMIT_BREAKAWAY_OK, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, + JOB_OBJECT_LIMIT_PRIORITY_CLASS, JOB_OBJECT_LIMIT_SCHEDULING_CLASS, + JOB_OBJECT_LIMIT_WORKINGSET, }, Threading::{ ABOVE_NORMAL_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS, @@ -61,6 +62,14 @@ impl ExtendedLimitInfo { self } + /// If any process associated with the job creates a child process using + /// this flag, the child process is not associated with the job. + pub fn limit_breakaway_ok(&mut self) -> &mut Self { + self.0.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_BREAKAWAY_OK; + + self + } + /// Causes all processes associated with the job to use the same priority class. /// Note: Processes and threads cannot modify their priority class. /// The calling process must enable the `SE_INC_BASE_PRIORITY_NAME` privilege.