Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: shpool builds on mac #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if mac doesn't support ptsname_r, maybe we need to create the pty with openpty?

Also, just noticing this now, but this fork code is wrong. You aren't allowed to allocate in the child after a fork() call and this vec! constructor does so. We should probably fix that at some point.

//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
Loading