breaking: Remove the pre-exec extension function

The purpose for removing this function is twofold:

- It is the only unsafe code in this crate that can't be realistically
  replaced with safe code.
- It is a footgun anyways, and can be done anyways with Into::into() if
   users really want it.

This is a breaking change.

Signed-off-by: John Nunley <dev@notgull.net>
This commit is contained in:
John Nunley 2023-10-07 21:06:27 -07:00 committed by GitHub
parent 513b9262d7
commit b29af2b72c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 41 deletions

View File

@ -20,39 +20,6 @@ pub trait CommandExt: crate::sealed::Sealed {
/// the same semantics as the `uid` field.
fn gid(&mut self, id: u32) -> &mut Command;
/// Schedules a closure to be run just before the `exec` function is
/// invoked.
///
/// The closure is allowed to return an I/O error whose OS error code will
/// be communicated back to the parent and returned as an error from when
/// the spawn was requested.
///
/// Multiple closures can be registered and they will be called in order of
/// their registration. If a closure returns `Err` then no further closures
/// will be called and the spawn operation will immediately return with a
/// failure.
///
/// # Safety
///
/// This closure will be run in the context of the child process after a
/// `fork`. This primarily means that any modifications made to memory on
/// behalf of this closure will **not** be visible to the parent process.
/// This is often a very constrained environment where normal operations
/// like `malloc` or acquiring a mutex are not guaranteed to work (due to
/// other threads perhaps still running when the `fork` was run).
///
/// This also means that all resources such as file descriptors and
/// memory-mapped regions got duplicated. It is your responsibility to make
/// sure that the closure does not violate library invariants by making
/// invalid use of these duplicates.
///
/// When this closure is run, aspects such as the stdio file descriptors and
/// working directory have successfully been changed, so output to these
/// locations may not appear where intended.
unsafe fn pre_exec<F>(&mut self, f: F) -> &mut Command
where
F: FnMut() -> io::Result<()> + Send + Sync + 'static;
/// Performs all the required setup by this `Command`, followed by calling
/// the `execvp` syscall.
///
@ -103,14 +70,6 @@ impl CommandExt for Command {
self
}
unsafe fn pre_exec<F>(&mut self, f: F) -> &mut Command
where
F: FnMut() -> io::Result<()> + Send + Sync + 'static,
{
self.inner.pre_exec(f);
self
}
fn exec(&mut self) -> io::Error {
self.inner.exec()
}