You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 925facd
Browse filesBrowse the repository at this point in the historyBrowse files
/// Kills what runs in a cgroup and below it, waits (2 s at most) for it to end, and removes the
202
202
/// cgroups, deepest first. Before Linux 5.14 (no `cgroup.kill`) each process listed is sent SIGKILL
203
-
/// until none is left (one forked meanwhile is listed in the next round).
203
+
/// until none is left (one forked meanwhile is listed in the next round). What is still in it after
204
+
/// the wait is said (`spawn::leave`): strobe ended it, and it did not go. A cgroup already removed
205
+
/// (ended by a stop, `end_all`) is nothing to end.
204
206
fnend(dir:&Path){
207
+
if !dir.exists(){
208
+
return;
209
+
}
205
210
let killed = std::fs::write(dir.join("cgroup.kill"),"1").is_ok();
206
211
let until = Instant::now() + Duration::from_secs(2);
207
212
whilepopulated(dir) && Instant::now() < until {
@@ -214,9 +219,28 @@ fn end(dir: &Path) {
214
219
}
215
220
std::thread::sleep(Duration::from_millis(5));
216
221
}
222
+
ifpopulated(dir){
223
+
for pid inpids(dir).unwrap_or_default(){
224
+
super::spawn::leave(Some(pid),"a process in the cgroup of a launch strobe ended","it was still running 2 s after strobe ended the cgroup's processes");
225
+
}
226
+
}
217
227
remove(dir);
218
228
}
219
229
230
+
/// Ends every launch cgroup this strobe still has (`end`), for a stop that exits at once: a process
231
+
/// that left its launch's tree and group (a crash reporter's handler, a daemon) is still in it, and
232
+
/// the cgroup strobe made is the proof that it is the launch's. All are killed first, then each waited
233
+
/// for.
234
+
pubfnend_all(){
235
+
let all:Vec<PathBuf> = std::mem::take(&mut*LAUNCHES.lock().unwrap_or_else(|e| e.into_inner())).into_iter().map(|(_, _, p)| p).collect();
236
+
for dir in&all {
237
+
let _ = std::fs::write(dir.join("cgroup.kill"),"1");
238
+
}
239
+
for dir in&all {
240
+
end(dir);
241
+
}
242
+
}
243
+
220
244
/// Whether process `pid` is in cgroup `dir` or one below it now (`/proc/<pid>/cgroup`'s v2 line).
Copy file name to clipboardExpand all lines: src/host/kill.rs
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@
47
47
//! | 1 | `kill_launch(pid, start)` | root, its tree, `-pid` | at the spawn (`Owned::start`); tree members from the walk's snapshot | strobe's own child, unreaped (Unix) or handle held (Windows); with `start`, nothing once it names another process; each member by its start, re-read (Linux: through a pidfd) right before |
48
48
//! | 2 | `kill_opened(pid, start)` | root, its tree (macOS: what is responsible to it by pid and start); never a group | the caller's (see each row) | root only at `start`, read again after the walk's list (a root that exited during it lends no children; macOS still ends what is responsible to it by pid and start); each member by its snapshot start, re-read right before; a reused root's tree left alone |
49
49
//! | 3 | `win::kill_tree` | `TerminateProcess` per tree member | the snapshot's creation time | the creation time read through the handle it terminates with; with a start, the root must have it |
50
-
//! | 4 | `spawn::end_launches` (a stop) | child: `kill_launch` + `-pgid`; opened app: `kill_opened`| child: at the spawn; opened app: `macos::launched` at the launch | child unreaped; opened app only with its launch-time start (an unadopted one has pid 0 and nothing is signalled) |
50
+
//! | 4 | `spawn::end_launches` (a stop) | child: `kill_launch` + `-pgid`; opened app: `kill_opened`; then every launch cgroup (`cgroup::end_all`, rows 14-15) or job (`TerminateJobObject`); `isolate::end_on_stop` then ends what carries each launch's stamp (`end_roots`) and says what is still running 2 s on | child: at the spawn; opened app: `macos::launched` at the launch | child unreaped; opened app only with its launch-time start (an unadopted one has pid 0 and nothing is signalled); a cgroup or job strobe made; a stamp re-read with the start time right before |
51
51
//! | 5 | `Owned::end_group` | as 4, then `TerminateJobObject`, `Child::kill` | as 4 | under the `LIVE` lock, before the reap |
52
52
//! | 6 | `close_job`, a job's last handle (`JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`), `tty` Windows | every process of the job | - | a job strobe made, by its handle |
53
53
//! | 7 | `Owned::run_to_exit` watchdog | `-pid` at the deadline | - | the child is unreaped until `wait4`; on a wait error the watchdog is joined and the group forgotten before returning |
@@ -63,7 +63,7 @@
63
63
//! | 17 | `tty` Unix: the pty master dropped (SIGHUP), `TIOCSWINSZ` (SIGWINCH) | the pty's foreground group | - | a pty strobe opened for its own child; the kernel signals only that terminal's group |
64
64
//! | 18 | `probe::sample::Capture::{stop, drop}` (macOS) | SIGINT, `Child::kill` | - | its own `sample` child while `try_wait` says it is not reaped |
65
65
//! | 19 | `Child::kill` (`engine`, `ffmpeg`, `track` alert shell, `macos::unregister`, `macos::ls_registered`, `spawn`) | own child | - | std signals none it reaped; each is waited for after |
66
-
//! | 20 | `unix_ctrl_c` (a second SIGINT or SIGTERM) | strobe itself (`raise`) | - | itself |
66
+
//! | 20 | `unix_ctrl_c` (a third SIGINT or SIGTERM, 300 ms or more after the second; a repeat within 300 ms is the same stop, and the second is a stop now: `spawn::stop_launches`, row 4, then exit 130) | strobe itself (`raise`) | - | itself |
67
67
//! | 21 | `probe::suspend` (Windows x64): stack sampling | `SuspendThread`, `ResumeThread`, memory reads | the look's snapshot (the set walked from the launch's root): each process's and thread's creation time | each process handle kept only while its creation time is the look's (`open_process`), each thread handle only while it is a thread of that pid created at the look's time (`open_thread`), both checked on the handle; else closed and counted unopened. A job's new process is opened by its parent's handle and creation time (`open_child`) |
68
68
//! | 22 | `android_chrome` (`adb shell am force-stop`) | a Chrome channel on a phone | - | never the stable channel; only a channel strobe started or one opted in with no tabs of the person's |
69
69
//! | 23 | `helper` (`schtasks /end`) | strobe's ETW helper task | - | the task name carries the user's RID; strobe's own |
left = homes.iter().flat_map(|h| ours(h)).collect();
557
+
}
558
+
for s in left {
559
+
leave(Some(s.pid),"a process launched for a launch strobe ended at a stop (it carries the launch's stamp)","it was still running 2 s after strobe ended it");
560
+
}
516
561
}
517
562
518
563
/// Whether a launch's pid names another process now: one started at another time than the launch
0 commit comments