Skip to content

Commit 1ea961f

Browse files
committed
disable jobserver on unix, if file descriptors are negative
1 parent d357534 commit 1ea961f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct FromEnvError {
1515
pub enum FromEnvErrorKind {
1616
/// There is no environment variable that describes jobserver to inherit.
1717
NoEnvVar,
18-
/// There is no jobserver in the environment variable.
18+
/// There is no jobserver in the environment variable, or it was disabled.
1919
/// Variables associated with Make can be used for passing data other than jobserver info.
2020
NoJobserver,
2121
/// Cannot parse jobserver environment variable value, incorrect format.

src/unix.rs

+6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ impl Client {
130130
.parse()
131131
.map_err(|e| FromEnvErrorInner::CannotParse(format!("cannot parse `write` fd: {e}")))?;
132132

133+
// If either or both of these file descriptors are negative,
134+
// it means the jobserver is disabled for this process.
135+
if read < 0 || write < 0 {
136+
return Err(FromEnvErrorInner::NoJobserver);
137+
}
138+
133139
// Ok so we've got two integers that look like file descriptors, but
134140
// for extra sanity checking let's see if they actually look like
135141
// valid files and instances of a pipe if feature enabled before we

0 commit comments

Comments
 (0)