@@ -111,10 +111,25 @@ pub trait CommandExt: Sealed {
111111 /// Schedules a closure to be run just before the `exec` function is
112112 /// invoked.
113113 ///
114- /// This method is stable and usable, but it should be unsafe. To fix
115- /// that, it got deprecated in favor of the unsafe [`pre_exec`].
114+ /// `before_exec` used to be a safe method, but it needs to be unsafe since the closure may only
115+ /// perform operations that are *async-signal-safe*. Hence it got deprecated in favor of the
116+ /// unsafe [`pre_exec`]. Meanwhile, Rust gained the ability to make an existing safe method
117+ /// fully unsafe in a new edition, which is how `before_exec` became `unsafe`It still also
118+ /// remains deprecated; `pre_exec` should be used instead.
116119 ///
117120 /// [`pre_exec`]: CommandExt::pre_exec
121+ #[ cfg( not( bootstrap) ) ]
122+ #[ stable( feature = "process_exec" , since = "1.15.0" ) ]
123+ #[ deprecated( since = "1.37.0" , note = "should be unsafe, use `pre_exec` instead" ) ]
124+ #[ rustc_deprecated_safe_2024]
125+ unsafe fn before_exec < F > ( & mut self , f : F ) -> & mut process:: Command
126+ where
127+ F : FnMut ( ) -> io:: Result < ( ) > + Send + Sync + ' static ,
128+ {
129+ unsafe { self . pre_exec ( f) }
130+ }
131+
132+ #[ cfg( bootstrap) ]
118133 #[ stable( feature = "process_exec" , since = "1.15.0" ) ]
119134 #[ deprecated( since = "1.37.0" , note = "should be unsafe, use `pre_exec` instead" ) ]
120135 fn before_exec < F > ( & mut self , f : F ) -> & mut process:: Command
0 commit comments