aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordivens <divens@users.noreply.github.com>2026-02-23 16:40:51 +0100
committerGitHub <noreply@github.com>2026-02-23 16:40:51 +0100
commitc80786f4ff54d2df7cb826f4cb9ed766e8f42bf4 (patch)
tree0f6bbcbc0cf572175b73a193443f1ba24b70019e
parentdocs(changelog): preserve cwd for editor panes (diff)
downloadsl0ppij-c80786f4ff54d2df7cb826f4cb9ed766e8f42bf4.tar.gz
sl0ppij-c80786f4ff54d2df7cb826f4cb9ed766e8f42bf4.tar.xz
sl0ppij-c80786f4ff54d2df7cb826f4cb9ed766e8f42bf4.zip
[Windows port PR7] refactor: upgrade sysinfo and add cross-compilation proof (#4759)
* refactor: platform-abstract path constants Add #[cfg(not(unix))] counterpart to unix_only module in consts.rs so path constants compile on non-Unix platforms. Move nix dependency to cfg(unix)-only in both zellij-utils and root crate. * refactor: Windows cross-compilation proof Enable all 5 core crates to compile for x86_64-pc-windows-gnu by fixing dependency issues and upgrading sysinfo. This validates that PRs 1.1–7.1 correctly gated all Unix-specific code behind cfg attributes. - Enable crossterm "windows" feature in workspace deps (no-op on non-Windows) - Remove dead mio dependency from zellij-client (zero imports) - Add Windows cross-compilation linker config to .cargo/config.toml - Upgrade sysinfo 0.22.5 → 0.33 (drops ntapi v0.3.7 packed struct UB) - Remove deprecated ProcessExt/SystemExt trait imports - Pid::from(i32) → Pid::from_u32(u32) - process.cwd() now returns Option<&Path> - process.cmd() now returns &[OsString] - Use precise ProcessRefreshKind (nothing + with_cwd/with_cmd) --------- Co-authored-by: divens <divens.dev@gmail.com>
-rw-r--r--.cargo/config.toml3
-rw-r--r--Cargo.lock84
-rw-r--r--Cargo.toml6
-rw-r--r--zellij-client/Cargo.toml1
-rw-r--r--zellij-server/Cargo.toml4
-rw-r--r--zellij-server/src/os_input_output.rs60
-rw-r--r--zellij-utils/Cargo.toml4
-rw-r--r--zellij-utils/src/consts.rs33
8 files changed, 152 insertions, 43 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 9b113f5d..f2455d45 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -5,3 +5,6 @@ xtask = "run --package xtask --"
x = "xtask"
q = "x run --quick-run"
make = "xtask deprecated"
+
+[target.x86_64-pc-windows-gnu]
+linker = "x86_64-w64-mingw32-gcc"
diff --git a/Cargo.lock b/Cargo.lock
index a0894889..c8a6b960 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -712,9 +712,9 @@ dependencies = [
[[package]]
name = "core-foundation-sys"
-version = "0.8.3"
+version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpufeatures"
@@ -800,8 +800,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
dependencies = [
"bitflags 2.5.0",
+ "crossterm_winapi",
"parking_lot 0.12.1",
"rustix 0.38.44",
+ "winapi",
+]
+
+[[package]]
+name = "crossterm_winapi"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
+dependencies = [
+ "winapi",
]
[[package]]
@@ -1640,7 +1651,7 @@ dependencies = [
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
- "windows-core",
+ "windows-core 0.52.0",
]
[[package]]
@@ -2465,9 +2476,9 @@ dependencies = [
[[package]]
name = "ntapi"
-version = "0.3.7"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
+checksum = "c70f219e21142367c70c0b30c6a9e3a14d55b4d12a204d897fbec83a0363f081"
dependencies = [
"winapi",
]
@@ -3789,16 +3800,15 @@ dependencies = [
[[package]]
name = "sysinfo"
-version = "0.22.5"
+version = "0.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f1bfab07306a27332451a662ca9c8156e3a9986f82660ba9c8e744fe8455d43"
+checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01"
dependencies = [
- "cfg-if",
"core-foundation-sys",
"libc",
+ "memchr",
"ntapi",
- "once_cell",
- "winapi",
+ "windows",
]
[[package]]
@@ -4839,6 +4849,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
+name = "windows"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
+dependencies = [
+ "windows-core 0.57.0",
+ "windows-targets 0.52.6",
+]
+
+[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4848,6 +4868,49 @@ dependencies = [
]
[[package]]
+name = "windows-core"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-result",
+ "windows-targets 0.52.6",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.96",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.96",
+]
+
+[[package]]
+name = "windows-result"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
+dependencies = [
+ "windows-targets 0.52.6",
+]
+
+[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5153,7 +5216,6 @@ dependencies = [
"isahc",
"lazy_static",
"log",
- "mio 0.8.11",
"nix 0.23.1",
"notify",
"num_cpus",
diff --git a/Cargo.toml b/Cargo.toml
index f0210685..80972838 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,11 +25,13 @@ interprocess = { workspace = true }
log = { workspace = true }
miette = { workspace = true }
names = { workspace = true }
-nix = { workspace = true }
suggest = { workspace = true }
thiserror = { workspace = true }
isahc = { workspace = true }
+[target.'cfg(unix)'.dependencies]
+nix = { workspace = true }
+
[dev-dependencies]
insta = { version = "1.6.0", features = ["backtrace"] }
ssh2 = "0.9.1"
@@ -74,7 +76,7 @@ ansi_term = { version = "0.12.1", default-features = false }
anyhow = { version = "1.0.70", default-features = false, features = ["backtrace", "std"] }
async-trait = { version = "0.1", default-features = false }
clap = { version = "3.2.2", default-features = false, features = ["env", "derive", "color", "std", "suggestions"] }
-crossterm = { version = "0.28", default-features = false }
+crossterm = { version = "0.28", default-features = false, features = ["windows"] }
daemonize = { version = "0.5", default-features = false }
dialoguer = { version = "0.10.4", default-features = false, features = ["password", "completion"] }
humantime = { version = "2.1.0", default-features = false }
diff --git a/zellij-client/Cargo.toml b/zellij-client/Cargo.toml
index 4b0afc8a..7bb51e83 100644
--- a/zellij-client/Cargo.toml
+++ b/zellij-client/Cargo.toml
@@ -26,7 +26,6 @@ dialoguer = { workspace = true }
interprocess = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
-mio = { version = "0.8.11", default-features = false, features = ['os-ext'] }
notify = { workspace = true }
num_cpus = { workspace = true }
regex = { workspace = true }
diff --git a/zellij-server/Cargo.toml b/zellij-server/Cargo.toml
index 237f5897..54f10a2c 100644
--- a/zellij-server/Cargo.toml
+++ b/zellij-server/Cargo.toml
@@ -26,7 +26,6 @@ kdl = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
notify-debouncer-full = { workspace = true }
-close_fds = "0.3.2"
prost = { workspace = true }
regex = { workspace = true }
semver = { version = "0.11.0", default-features = false }
@@ -35,7 +34,7 @@ serde_json = { workspace = true }
signal-hook = { workspace = true }
sixel-image = { version = "0.1.0", default-features = false }
sixel-tokenizer = { version = "0.1.0", default-features = false }
-sysinfo = { version = "0.22.5", default-features = false }
+sysinfo = { version = "0.33", default-features = false, features = ["system"] }
tempfile = { workspace = true }
tokio = { workspace = true }
typetag = { version = "0.1.7", default-features = false }
@@ -54,6 +53,7 @@ default-features = false
features = ["std"]
[target.'cfg(unix)'.dependencies]
+close_fds = "0.3.2"
daemonize = { workspace = true }
libc = { workspace = true }
nix = { workspace = true }
diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs
index 236d806a..19106388 100644
--- a/zellij-server/src/os_input_output.rs
+++ b/zellij-server/src/os_input_output.rs
@@ -8,7 +8,7 @@ use crate::os_input_output_unix::UnixPtyBackend as PtyBackendImpl;
use crate::os_input_output_windows::WindowsPtyBackend as PtyBackendImpl;
use interprocess;
-use sysinfo::{ProcessExt, ProcessRefreshKind, System, SystemExt};
+use sysinfo::{ProcessRefreshKind, ProcessesToUpdate, System, UpdateKind};
use tempfile::tempfile;
use zellij_utils::{
channels,
@@ -439,16 +439,17 @@ impl ServerOsApi for ServerOsInputOutput {
fn get_cwd(&self, pid: u32) -> Option<PathBuf> {
let mut system_info = System::new();
- // Update by minimizing information.
- // See https://docs.rs/sysinfo/0.22.5/sysinfo/struct.ProcessRefreshKind.html#
- let sysinfo_pid = sysinfo::Pid::from(pid as i32);
- system_info.refresh_process_specifics(sysinfo_pid, ProcessRefreshKind::default());
+ let sysinfo_pid = sysinfo::Pid::from_u32(pid);
+ let refresh_kind = ProcessRefreshKind::nothing().with_cwd(UpdateKind::Always);
+ system_info.refresh_processes_specifics(
+ ProcessesToUpdate::Some(&[sysinfo_pid]),
+ false,
+ refresh_kind,
+ );
if let Some(process) = system_info.process(sysinfo_pid) {
- let cwd = process.cwd();
- let cwd_is_empty = cwd.iter().next().is_none();
- if !cwd_is_empty {
- return Some(process.cwd().to_path_buf());
+ if let Some(cwd) = process.cwd() {
+ return Some(cwd.to_path_buf());
}
}
None
@@ -459,24 +460,31 @@ impl ServerOsApi for ServerOsInputOutput {
let mut cwds = HashMap::new();
let mut cmds = HashMap::new();
+ let sysinfo_pids: Vec<sysinfo::Pid> =
+ pids.iter().map(|&p| sysinfo::Pid::from_u32(p)).collect();
+ let refresh_kind = ProcessRefreshKind::nothing()
+ .with_cwd(UpdateKind::Always)
+ .with_cmd(UpdateKind::Always);
+ system_info.refresh_processes_specifics(
+ ProcessesToUpdate::Some(&sysinfo_pids),
+ false,
+ refresh_kind,
+ );
+
for pid in pids {
- // Update by minimizing information.
- // See https://docs.rs/sysinfo/0.22.5/sysinfo/struct.ProcessRefreshKind.html#
- let sysinfo_pid = sysinfo::Pid::from(pid as i32);
- let is_found =
- system_info.refresh_process_specifics(sysinfo_pid, ProcessRefreshKind::default());
- if is_found {
- if let Some(process) = system_info.process(sysinfo_pid) {
- let cwd = process.cwd();
- let cmd = process.cmd();
- let cwd_is_empty = cwd.iter().next().is_none();
- if !cwd_is_empty {
- cwds.insert(pid, process.cwd().to_path_buf());
- }
- let cmd_is_empty = cmd.iter().next().is_none();
- if !cmd_is_empty {
- cmds.insert(pid, process.cmd().to_vec());
- }
+ let sysinfo_pid = sysinfo::Pid::from_u32(pid);
+ if let Some(process) = system_info.process(sysinfo_pid) {
+ if let Some(cwd) = process.cwd() {
+ cwds.insert(pid, cwd.to_path_buf());
+ }
+ let cmd = process.cmd();
+ if !cmd.is_empty() {
+ cmds.insert(
+ pid,
+ cmd.iter()
+ .map(|s| s.to_string_lossy().into_owned())
+ .collect(),
+ );
}
}
}
diff --git a/zellij-utils/Cargo.toml b/zellij-utils/Cargo.toml
index d1db4945..92cd3593 100644
--- a/zellij-utils/Cargo.toml
+++ b/zellij-utils/Cargo.toml
@@ -24,7 +24,6 @@ kdl = { version = "4.5.0", default-features = false, features = ["span"] }
lazy_static = { workspace = true }
log = { workspace = true }
miette = { workspace = true }
-nix = { workspace = true }
percent-encoding = { version = "2.1.0", default-features = false, features = ["std"] }
prost = { workspace = true }
serde = { workspace = true }
@@ -56,6 +55,9 @@ names = { workspace = true }
rusqlite = { version = "0.30", default-features = false, features = ["bundled"], optional = true }
notify = { workspace = true }
+[target.'cfg(unix)'.dependencies]
+nix = { workspace = true }
+
[dev-dependencies]
insta = { version = "1.6.0", features = ["backtrace"] }
expect-test = "1.4.1"
diff --git a/zellij-utils/src/consts.rs b/zellij-utils/src/consts.rs
index 102246c0..ef28b9a9 100644
--- a/zellij-utils/src/consts.rs
+++ b/zellij-utils/src/consts.rs
@@ -194,3 +194,36 @@ mod unix_only {
pub static ref WEBSERVER_SOCKET_PATH: PathBuf = ZELLIJ_SOCK_DIR.join("web_server_bus");
}
}
+
+#[cfg(not(unix))]
+pub use not_unix::*;
+
+#[cfg(not(unix))]
+mod not_unix {
+ use super::*;
+ use crate::envs;
+ pub use crate::shared::set_permissions;
+ use lazy_static::lazy_static;
+ use std::env::temp_dir;
+
+ pub const ZELLIJ_SOCK_MAX_LENGTH: usize = 256;
+
+ lazy_static! {
+ pub static ref ZELLIJ_TMP_DIR: PathBuf = temp_dir().join("zellij");
+ pub static ref ZELLIJ_TMP_LOG_DIR: PathBuf = ZELLIJ_TMP_DIR.join("zellij-log");
+ pub static ref ZELLIJ_TMP_LOG_FILE: PathBuf = ZELLIJ_TMP_LOG_DIR.join("zellij.log");
+ pub static ref ZELLIJ_SOCK_DIR: PathBuf = {
+ let mut ipc_dir = envs::get_socket_dir().map_or_else(
+ |_| {
+ ZELLIJ_PROJ_DIR
+ .runtime_dir()
+ .map_or_else(|| ZELLIJ_TMP_DIR.clone(), |p| p.to_owned())
+ },
+ PathBuf::from,
+ );
+ ipc_dir.push(CLIENT_SERVER_CONTRACT_DIR.clone());
+ ipc_dir
+ };
+ pub static ref WEBSERVER_SOCKET_PATH: PathBuf = ZELLIJ_SOCK_DIR.join("web_server_bus");
+ }
+}