From 48bb048d75c50baceba4dccd6c5dc1fff23a72fc Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Mon, 9 Mar 2026 13:42:17 +0100 Subject: reorg --- src/unix.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/unix.rs') diff --git a/src/unix.rs b/src/unix.rs index f26dc8c..967c4fe 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -13,11 +13,15 @@ use std::process::exit; use std::sync::Arc; use std::sync::Mutex; use std::thread; +use crate::Session; -use libc::socket; +fn handle_server(session: Arc>, stream: UnixStream) -> io::Result<()> { + todo!() +} -use crate::BString; -use crate::Session; +fn handle_client(stream: UnixStream) -> io::Result<()> { + todo!() +} fn user_function_res(sock: &OsStr) -> io::Result<()> { let sock = UnixStream::connect(sock)?; @@ -38,7 +42,9 @@ pub fn maybe_run_defined_function() { let program_name = program_name.as_bytes(); if !program_name.contains(&b'/') && program_name != b"pish" { if let Some(socket) = std::env::var_os("PISH_SOCKET") { - let _ = user_function_res(&socket); + if let Ok(stream) = UnixStream::connect(socket) { + let _ = handle_client(stream); + } exit(-1); } } @@ -126,8 +132,9 @@ pub fn listen(session: Arc>) -> SocketDropper { Ok(se) if se.socket_running.is_none() => break, _ => (), } - if let Ok(_stream) = stream { - todo!("handle client") + if let Ok(stream) = stream { + let se = se.clone(); + thread::spawn(move || handle_server(se, stream)); } } }); -- cgit v1.2.3