@@ -63,6 +63,8 @@ public abstract class AsyncTask : GLib.Object{
6363 public int64 prg_count = 0 ;
6464 public int64 prg_count_total = 0 ;
6565
66+ public bool io_nice = true ; // renice child processes to IDlE PRIO
67+
6668 // signals
6769 public signal void stdout_line_read (string line );
6870 public signal void stderr_line_read (string line );
@@ -112,7 +114,7 @@ public abstract class AsyncTask : GLib.Object{
112114 }
113115
114116 protected abstract string build_script ();
115-
117+
116118 protected virtual bool begin () {
117119 status = AppStatus . RUNNING ;
118120
@@ -131,20 +133,27 @@ public abstract class AsyncTask : GLib.Object{
131133 timer = new GLib .Timer ();
132134 timer. start();
133135
136+ GLib . SpawnChildSetupFunc ? childsetup = null ;
137+
138+ if (this . io_nice) {
139+ // change io prio of process, right before it execs
140+ childsetup = () = > TeeJee . ProcessHelper . ioprio_set(0 , IoPrio . prioValue(IoPrio . PrioClass . IDLE , 0 ));
141+ }
142+
134143 // execute script file
135144 Process . spawn_async_with_pipes(
136145 working_dir, // working dir
137146 spawn_args, // argv
138147 spawn_env, // environment
139148 SpawnFlags . SEARCH_PATH ,
140- null , // child_setup
149+ childsetup , // child_setup
141150 out child_pid,
142151 out input_fd,
143152 out output_fd,
144153 out error_fd);
145154
146155 log_debug(" AsyncTask: child_pid: %d " . printf(child_pid));
147-
156+
148157 // create stream readers
149158 UnixOutputStream uos_in = new UnixOutputStream (input_fd, true );
150159 UnixInputStream uis_out = new UnixInputStream (output_fd, true );
0 commit comments