Skip to content

Commit 953dc81

Browse files
committed
feat: reintroduce process-wick sidecar for child process management
1 parent 62574a1 commit 953dc81

File tree

5 files changed

+57
-59
lines changed

5 files changed

+57
-59
lines changed

justfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ update-binaries TARGET_TRIPLE="":
736736

737737

738738
UV_ASSETS_BASE_URL = "https://github.com/astral-sh/uv/releases/latest/download"
739+
PROCESS_WICK_ASSETS_BASE_URL = "https://github.com/itstauq/process-wick/releases/latest/download"
739740

740741
all_assets = [
741742
Asset(
@@ -758,6 +759,27 @@ update-binaries TARGET_TRIPLE="":
758759
target_triple="x86_64-unknown-linux-gnu",
759760
binary_names=["uv", "uvx"]
760761
),
762+
763+
Asset(
764+
url=f"{PROCESS_WICK_ASSETS_BASE_URL}/process-wick-aarch64-apple-darwin",
765+
target_triple="aarch64-apple-darwin",
766+
binary_names=["process-wick-aarch64-apple-darwin"]
767+
),
768+
Asset(
769+
url=f"{PROCESS_WICK_ASSETS_BASE_URL}/process-wick-x86_64-apple-darwin",
770+
target_triple="x86_64-apple-darwin",
771+
binary_names=["process-wick-x86_64-apple-darwin"]
772+
),
773+
Asset(
774+
url=f"{PROCESS_WICK_ASSETS_BASE_URL}/process-wick-x86_64-pc-windows-msvc.exe",
775+
target_triple="x86_64-pc-windows-msvc",
776+
binary_names=["process-wick-x86_64-pc-windows-msvc.exe"]
777+
),
778+
Asset(
779+
url=f"{PROCESS_WICK_ASSETS_BASE_URL}/process-wick-x86_64-unknown-linux-gnu",
780+
target_triple="x86_64-unknown-linux-gnu",
781+
binary_names=["process-wick-x86_64-unknown-linux-gnu"]
782+
),
761783
]
762784

763785
assets_to_download = [asset for asset in all_assets if asset.target_triple == selected_target_triple]

src-tauri/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ pub fn run() {
124124
.expect("error while building tauri application")
125125
.run(move |_app_handle, event| match event {
126126
tauri::RunEvent::Exit => {
127-
log::info!("Exit requested - cleaning up child processes");
128-
utils::cleanup_child_processes();
127+
log::info!("Exiting application");
129128
}
130129
_ => {}
131130
});

src-tauri/src/utils.rs

Lines changed: 30 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,36 @@ pub fn _setup_sidecars_for_release_builds(
174174

175175
app_handle_clone.exit(daemon_sidecar_exit_code);
176176
});
177+
178+
let child_process_pids = _find_child_process_pids();
179+
180+
let (_, process_wick_sidecar) = app
181+
.shell()
182+
.sidecar("process-wick")
183+
.unwrap()
184+
.args(["--targets", &child_process_pids.join(",")])
185+
.spawn()
186+
.expect("Failed to spawn sidecar");
187+
log::info!(
188+
"Process wick sidecar spawned with PID: {}",
189+
process_wick_sidecar.pid()
190+
);
191+
}
192+
193+
#[cfg(not(debug_assertions))]
194+
pub fn _find_child_process_pids() -> Vec<String> {
195+
let mut sys = System::new_all();
196+
sys.refresh_all();
197+
let current_pid = sysinfo::Pid::from_u32(std::process::id());
198+
let mut child_process_pids = Vec::new();
199+
for (pid, process) in sys.processes() {
200+
if let Some(parent_pid) = process.parent() {
201+
if parent_pid == current_pid {
202+
child_process_pids.push(pid.to_string());
203+
}
204+
}
205+
}
206+
child_process_pids
177207
}
178208

179209
pub fn _setup_system_tray(app: &AppHandle) {
@@ -331,57 +361,3 @@ pub fn _generate_secure_token() -> String {
331361
.expect("Failed to generate secure token key");
332362
hex::encode(key)
333363
}
334-
335-
/// Lists and kills all child processes of the current process
336-
pub fn cleanup_child_processes() {
337-
log::info!("Starting child process cleanup");
338-
339-
let mut sys = System::new_all();
340-
sys.refresh_all();
341-
342-
let current_pid = sysinfo::Pid::from_u32(std::process::id());
343-
let mut child_processes = Vec::new();
344-
345-
// Find all child processes
346-
for (pid, process) in sys.processes() {
347-
if let Some(parent_pid) = process.parent() {
348-
if parent_pid == current_pid {
349-
child_processes.push((*pid, process.name().to_string_lossy().to_string()));
350-
log::info!(
351-
"Found child process: PID={}, Name={}",
352-
pid,
353-
process.name().to_string_lossy()
354-
);
355-
}
356-
}
357-
}
358-
359-
if child_processes.is_empty() {
360-
log::info!("No child processes found to clean up");
361-
return;
362-
}
363-
364-
log::info!(
365-
"Found {} child processes, attempting to terminate them",
366-
child_processes.len()
367-
);
368-
369-
// Kill each child process
370-
for (pid, name) in child_processes {
371-
match sys.process(pid) {
372-
Some(process) => {
373-
log::info!("Terminating child process: PID={}, Name={}", pid, name);
374-
if process.kill() {
375-
log::info!("Successfully terminated process {} ({})", pid, name);
376-
} else {
377-
log::warn!("Failed to terminate process {} ({})", pid, name);
378-
}
379-
}
380-
None => {
381-
log::warn!("Process {} ({}) no longer exists", pid, name);
382-
}
383-
}
384-
}
385-
386-
log::info!("Child process cleanup completed");
387-
}

src-tauri/src/version.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pub const DESKTOP_VERSION: &str = "0.2.0";
2-
pub const DESKTOP_HASH: &str = "fc7c12e";
3-
pub const DESKTOP_BUILD: &str = "2025-06-24T15:49:05+05:30";
1+
pub const DESKTOP_VERSION: &str = "0.2.2";
2+
pub const DESKTOP_HASH: &str = "d2c508d";
3+
pub const DESKTOP_BUILD: &str = "2025-06-25T12:43:33+05:30";
44
pub const DAEMON_VERSION: &str = "0.6.0";
55
pub const DAEMON_HASH: &str = "6b8502c";
66
pub const DAEMON_BUILD: &str = "2025-06-24T14:05:14+05:30";

src-tauri/tauri.conf.release-extras.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"bundle": {
33
"externalBin": [
4+
"./target/binaries/process-wick",
45
"./target/binaries/uv",
56
"./target/binaries/uvx",
67
"./target/binaries/syftboxd"

0 commit comments

Comments
 (0)