Skip to content

Commit 74ca02d

Browse files
committed
Rm imp::Client::pre_run
On Unix `Client` always clone the fds and now it also records the original fd used to construct the `Client` and pass it to children, there's no need to unset `CLOEXEC` before exec anymore. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 2729e53 commit 74ca02d

File tree

4 files changed

+0
-42
lines changed

4 files changed

+0
-42
lines changed

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,6 @@ impl Client {
504504
Cmd: Command,
505505
F: FnOnce(&mut Cmd) -> io::Result<R>,
506506
{
507-
// Register one-time callback on unix to unset CLO_EXEC
508-
// in child process.
509-
self.0.inner.pre_run(&mut cmd);
510-
511507
let arg = self.0.inner.string_arg();
512508
// Older implementations of make use `--jobserver-fds` and newer
513509
// implementations use `--jobserver-auth`, pass both to try to catch

src/unix.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -297,29 +297,6 @@ impl Client {
297297
}
298298
}
299299

300-
pub fn pre_run<Cmd>(&self, cmd: &mut Cmd)
301-
where
302-
Cmd: Command,
303-
{
304-
let read = self.read.as_raw_fd();
305-
let write = self.write.as_raw_fd();
306-
307-
let mut fds = Some([read, write]);
308-
309-
let f = move || {
310-
// Make sure this function is executed only once,
311-
// so that the command may be reused with another
312-
// Client.
313-
for fd in fds.take().iter().flatten() {
314-
set_cloexec(*fd, false)?;
315-
}
316-
317-
Ok(())
318-
};
319-
320-
unsafe { cmd.pre_exec(f) };
321-
}
322-
323300
pub fn available(&self) -> io::Result<usize> {
324301
let mut len = MaybeUninit::<c_int>::uninit();
325302
cvt(unsafe { libc::ioctl(self.read.as_raw_fd(), libc::FIONREAD, len.as_mut_ptr()) })?;

src/wasm.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ impl Client {
9898
);
9999
}
100100

101-
pub fn pre_run<Cmd>(&self, _cmd: &mut Cmd) {
102-
panic!(
103-
"On this platform there is no cross process jobserver support,
104-
so Client::configure_and_run is not supported."
105-
);
106-
}
107-
108101
pub fn available(&self) -> io::Result<usize> {
109102
Ok(*self.count())
110103
}

src/windows.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,6 @@ impl Client {
176176
Cow::Borrowed(&self.name)
177177
}
178178

179-
pub fn pre_run<Cmd>(&self, _cmd: &mut Cmd)
180-
where
181-
Cmd: Command,
182-
{
183-
// nothing to do here, we gave the name of our semaphore to the
184-
// child above
185-
}
186-
187179
pub fn available(&self) -> io::Result<usize> {
188180
// Can't read value of a semaphore on Windows, so
189181
// try to acquire without sleeping, since we can find out the

0 commit comments

Comments
 (0)