Skip to content

Commit

Permalink
fix: shpool builds on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmlhermitte committed Jun 14, 2024
1 parent 7c867a3 commit 16b9d1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/fork/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ impl Fork {
-1 => Err(ForkError::Failure),
0 => {
let mut ptsname_buf = vec![0; MAX_PTS_NAME];
if let Err(cause) = master.ptsname_r(&mut ptsname_buf) {
return Err(ForkError::BadMaster(cause));
}
//if let Err(cause) = master.ptsname_r(&mut ptsname_buf) {
//return Err(ForkError::BadMaster(cause));
//}
// TODO: replace this
// ensure null termination
let last_idx = ptsname_buf.len() - 1;
ptsname_buf[last_idx] = 0;
Expand Down
15 changes: 8 additions & 7 deletions src/fork/pty/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ impl Master {
if let Some(fd) = self.pty {
// Safety: the vector's memory is valid for the duration
// of the call
unsafe {
let data: *mut u8 = &mut buf[0];
match libc::ptsname_r(fd, data as *mut libc::c_char, buf.len()) {
0 => Ok(()),
_ => Err(MasterError::PtsnameError), // should probably capture errno
}
}
//unsafe {
//let data: *mut u8 = &mut buf[0];
//match libc::ptsname_r(fd) {
//0 => Ok(()),
//_ => Err(MasterError::PtsnameError), // should probably capture errno
//}
//}
Ok(())
} else {
Err(MasterError::NoFdError)
}
Expand Down

0 comments on commit 16b9d1a

Please sign in to comment.