aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonas Maier <>2026-03-09 13:42:17 +0100
committerJonas Maier <>2026-03-09 13:42:17 +0100
commit48bb048d75c50baceba4dccd6c5dc1fff23a72fc (patch)
tree697b9fe460a0431e9b09b2ae84bd4dfe965f2200 /src
parent35dd10890d7c6d1023d6c8647c0984b69b811410 (diff)
downloadpish-48bb048d75c50baceba4dccd6c5dc1fff23a72fc.tar.gz
reorg
Diffstat (limited to 'src')
-rw-r--r--src/unix.rs19
1 files changed, 13 insertions, 6 deletions
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<Mutex<Session>>, 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<Mutex<Session>>) -> 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));
}
}
});