diff options
Diffstat (limited to 'src/export_fun.rs')
| -rw-r--r-- | src/export_fun.rs | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/export_fun.rs b/src/export_fun.rs index 934b81c..006bec3 100644 --- a/src/export_fun.rs +++ b/src/export_fun.rs @@ -5,6 +5,7 @@ use std::env::current_exe; use std::ffi::OsStr; use std::fs; use std::io; +use std::io::Read; use std::io::Write; use std::os::unix::ffi::OsStrExt; use std::os::unix::fs::symlink; @@ -22,23 +23,31 @@ fn handle_server(session: Arc<Mutex<Session>>, stream: UnixStream) -> io::Result todo!() } -fn handle_client(stream: UnixStream) -> io::Result<()> { +fn handle_client(mut stream: UnixStream) -> io::Result<()> { println!("uhh hi"); - todo!() -} - -fn user_function_res(sock: &OsStr) -> io::Result<()> { - let sock = UnixStream::connect(sock)?; + // give up all my file descriptors descriptors let mut ancillary_buffer = [0; 128]; let mut ancillary = SocketAncillary::new(&mut ancillary_buffer[..]); ancillary.add_fds(&[0, 1, 2]); - let buf = [0; 8]; - let mut bufs = &mut [io::IoSlice::new(&buf[..])][..]; - sock.send_vectored_with_ancillary(bufs, &mut ancillary)?; + // cli params + let buf = crate::serialization::serialize_cli_args(); + let bufs = &mut [io::IoSlice::new(&buf[..])][..]; - todo!() + // send + stream.send_vectored_with_ancillary(bufs, &mut ancillary)?; + + // recv exit code + let mut exit_buf = [0; 4]; + let res = stream.read_exact(&mut exit_buf); + + let exit_code = match res { + Ok(_) => i32::from_le_bytes(exit_buf), + Err(_) => -2, + }; + + exit(exit_code) } pub fn maybe_run_defined_function() { |
