@@ -111,7 +111,7 @@ impl Display for ActionResult {
111111///
112112/// But we don't know if the process of pid are exist, if [None], the process doesn't exist
113113#[ cfg( target_os = "linux" ) ]
114- fn set_priority ( pid : u32 , prio : & Priority ) -> Option < ActionResult > {
114+ fn set_priority ( pid : u32 , prio : & Priority , take_action : bool ) -> Option < ActionResult > {
115115 use libc:: { getpriority, setpriority, PRIO_PROCESS } ;
116116 use nix:: errno:: Errno ;
117117
@@ -136,6 +136,10 @@ fn set_priority(pid: u32, prio: &Priority) -> Option<ActionResult> {
136136 prio
137137 } ;
138138
139+ if !take_action {
140+ return Some ( ActionResult :: Success ) ;
141+ }
142+
139143 let prio = match prio {
140144 Priority :: Increase ( prio) => current_priority + * prio as i32 ,
141145 Priority :: Decrease ( prio) => current_priority - * prio as i32 ,
@@ -159,11 +163,15 @@ fn set_priority(pid: u32, prio: &Priority) -> Option<ActionResult> {
159163
160164// TODO: Implemented this on other platform
161165#[ cfg( not( target_os = "linux" ) ) ]
162- fn set_priority ( _pid : u32 , _prio : & Priority ) -> Option < ActionResult > {
166+ fn set_priority ( _pid : u32 , _prio : & Priority , _take_action : bool ) -> Option < ActionResult > {
163167 None
164168}
165169
166- pub ( crate ) fn perform_action ( pids : & [ u32 ] , prio : & Priority ) -> Vec < Option < ActionResult > > {
167- let f = |pid : & u32 | set_priority ( * pid, prio) ;
170+ pub ( crate ) fn perform_action (
171+ pids : & [ u32 ] ,
172+ prio : & Priority ,
173+ take_action : bool ,
174+ ) -> Vec < Option < ActionResult > > {
175+ let f = |pid : & u32 | set_priority ( * pid, prio, take_action) ;
168176 pids. iter ( ) . map ( f) . collect ( )
169177}
0 commit comments