| Active (** we provide a function which writes into the compressor and a fd output *)
| Passive (** we provide an fd input and a function which reads from the compressor *)
-(* renice/ionice the pid with lowest priority so that it doesn't *)
-(* use up all cpu resources in dom0 *)
-let lower_priority pid =
- let pid=Printf.sprintf "%d" (Forkhelpers.getpid pid) in
- (* renice 19 -p pid *)
- let renice="/usr/bin/renice" in
- let renice_args = ["19";"-p";pid] in
- let _=Forkhelpers.execute_command_get_output renice renice_args in
- (* ionice -c 3 [idle] -p pid *)
+(* start cmd with lowest priority so that it doesn't
+ use up all cpu resources in dom0
+*)
+let lower_priority cmd args =
let ionice="/usr/bin/ionice" in
- let ionice_args = ["-c";"3";"-p";pid] in
- let _=Forkhelpers.execute_command_get_output ionice ionice_args in
- ()
+ let ionice_args=["-c";"3"] in (*io idle*)
+ let nice="/bin/nice" in
+ let nice_args=["-n";"19"] in (*lowest priority*)
+ let extra_args=nice_args@[ionice]@ionice_args in
+ let new_cmd=nice in
+ let new_args=extra_args@[cmd]@args in
+ (new_cmd,new_args)
(** Runs a zcat process which is either:
i) a compressor; or (ii) a decompressor
Some zcat_in, (* output goes into the pipe+fn *)
zcat_in, (* we close this now *)
zcat_out in (* close this before waitpid *)
+ let (gzip,args)=lower_priority gzip args in
let pid = Forkhelpers.safe_close_and_exec stdin stdout None [] gzip args in
close close_now;
finally
(fun () ->
- (try lower_priority pid with _->()); (* lowest priority to gzip *)
f close_later
)
(fun () ->