Skip to content

Commit

Permalink
disable jobserver on unix, if file descriptors are negative
Browse files Browse the repository at this point in the history
  • Loading branch information
belovdv committed Feb 1, 2024
1 parent d357534 commit 1ea961f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct FromEnvError {
pub enum FromEnvErrorKind {
/// There is no environment variable that describes jobserver to inherit.
NoEnvVar,
/// There is no jobserver in the environment variable.
/// There is no jobserver in the environment variable, or it was disabled.
/// Variables associated with Make can be used for passing data other than jobserver info.
NoJobserver,
/// Cannot parse jobserver environment variable value, incorrect format.
Expand Down
6 changes: 6 additions & 0 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ impl Client {
.parse()
.map_err(|e| FromEnvErrorInner::CannotParse(format!("cannot parse `write` fd: {e}")))?;

// If either or both of these file descriptors are negative,
// it means the jobserver is disabled for this process.
if read < 0 || write < 0 {
return Err(FromEnvErrorInner::NoJobserver);
}

// Ok so we've got two integers that look like file descriptors, but
// for extra sanity checking let's see if they actually look like
// valid files and instances of a pipe if feature enabled before we
Expand Down

0 comments on commit 1ea961f

Please sign in to comment.