gglib_core/paths/pids.rs
1//! PID file directory path resolution.
2//!
3//! Provides the canonical location for storing process ID files to track
4//! running llama-server instances.
5
6use std::path::PathBuf;
7
8use super::PathError;
9use super::platform::data_root;
10
11/// Returns the directory where PID files are stored.
12///
13/// Location: `~/.gglib/pids/` (or equivalent data root)
14///
15/// This directory is used to track running llama-server processes across
16/// application restarts, enabling cleanup of orphaned processes.
17pub fn pids_dir() -> Result<PathBuf, PathError> {
18 Ok(data_root()?.join("pids"))
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn pids_dir_is_under_data_root() {
27 let pids = pids_dir().expect("pids_dir failed");
28 let data = data_root().expect("data_root failed");
29 assert!(pids.starts_with(&data));
30 assert!(pids.ends_with("pids"));
31 }
32}