@@ -231,13 +231,6 @@ impl Client {
231231 /// result with the connected client will be returned. In other cases
232232 /// result will contain `Err(FromEnvErr)`.
233233 ///
234- /// Note that on Unix the `Client` returned **takes ownership of the file
235- /// descriptors specified in the environment**. Jobservers on Unix are
236- /// implemented with `pipe` file descriptors, and they're inherited from
237- /// parent processes. This `Client` returned takes ownership of the file
238- /// descriptors for this process and will close the file descriptors after
239- /// this value is dropped.
240- ///
241234 /// Additionally on Unix this function will configure the file descriptors
242235 /// with `CLOEXEC` so they're not automatically inherited by spawned
243236 /// children.
@@ -256,11 +249,7 @@ impl Client {
256249 /// make sure to take ownership properly of the file descriptors passed
257250 /// down, if any.
258251 ///
259- /// It's generally unsafe to call this function twice in a program if the
260- /// previous invocation returned `Some`.
261- ///
262- /// Note, though, that on Windows it should be safe to call this function
263- /// any number of times.
252+ /// It is ok to call this function any number of times.
264253 pub unsafe fn from_env_ext ( check_pipe : bool ) -> FromEnv {
265254 let ( env, var_os) = match [ "CARGO_MAKEFLAGS" , "MAKEFLAGS" , "MFLAGS" ]
266255 . iter ( )
@@ -293,6 +282,19 @@ impl Client {
293282 /// environment.
294283 ///
295284 /// Wraps `from_env_ext` and discards error details.
285+ ///
286+ /// # Safety
287+ ///
288+ /// This function is `unsafe` to call on Unix specifically as it
289+ /// transitively requires usage of the `from_raw_fd` function, which is
290+ /// itself unsafe in some circumstances.
291+ ///
292+ /// It's recommended to call this function very early in the lifetime of a
293+ /// program before any other file descriptors are opened. That way you can
294+ /// make sure to take ownership properly of the file descriptors passed
295+ /// down, if any.
296+ ///
297+ /// It is ok to call this function any number of times.
296298 pub unsafe fn from_env ( ) -> Option < Client > {
297299 Self :: from_env_ext ( false ) . client . ok ( )
298300 }
0 commit comments