MCPcopy Create free account
hub / github.com/Qovery/engine / kill

Method kill

lib-engine/src/cmd/command.rs:168–190  ·  view source on GitHub ↗
(&self, cmd_handle: &mut Child)

Source from the content-addressed store, hash-verified

166 }
167
168 fn kill(&self, cmd_handle: &mut Child) {
169 info!("Killing command: {:?}", cmd_handle);
170
171 // cmd handle kill() send a SIGKILL which is a bit hard
172 // First send a SIGINT and allow the process to gracefully shutdown
173 unsafe {
174 let pid = cmd_handle.id() as i32;
175 let _ = libc::kill(pid, libc::SIGINT);
176 }
177
178 // We wait for the process to gracefully shutdown
179 // or else we send a SIGKILL to force kill it
180 let killed_since = Instant::now();
181 while let Ok(None) = cmd_handle.try_wait() {
182 if killed_since.elapsed() > self.kill_grace_period {
183 info!("Command still running after grace period, hard killing it");
184 let _ = cmd_handle.kill();
185 }
186 std::thread::sleep(Duration::from_millis(500));
187 }
188
189 let _ = cmd_handle.wait();
190 }
191
192 fn exec(&mut self) -> Result<(), CommandError> {
193 self.exec_with_abort(

Callers 2

exec_with_abortMethod · 0.45
stopMethod · 0.45

Calls 1

idMethod · 0.45

Tested by

no test coverage detected