@@ -231,13 +231,6 @@ impl Client {
231
231
/// result with the connected client will be returned. In other cases
232
232
/// result will contain `Err(FromEnvErr)`.
233
233
///
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
- ///
241
234
/// Additionally on Unix this function will configure the file descriptors
242
235
/// with `CLOEXEC` so they're not automatically inherited by spawned
243
236
/// children.
@@ -256,11 +249,7 @@ impl Client {
256
249
/// make sure to take ownership properly of the file descriptors passed
257
250
/// down, if any.
258
251
///
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.
264
253
pub unsafe fn from_env_ext ( check_pipe : bool ) -> FromEnv {
265
254
let ( env, var_os) = match [ "CARGO_MAKEFLAGS" , "MAKEFLAGS" , "MFLAGS" ]
266
255
. iter ( )
@@ -299,6 +288,19 @@ impl Client {
299
288
/// environment.
300
289
///
301
290
/// Wraps `from_env_ext` and discards error details.
291
+ ///
292
+ /// # Safety
293
+ ///
294
+ /// This function is `unsafe` to call on Unix specifically as it
295
+ /// transitively requires usage of the `from_raw_fd` function, which is
296
+ /// itself unsafe in some circumstances.
297
+ ///
298
+ /// It's recommended to call this function very early in the lifetime of a
299
+ /// program before any other file descriptors are opened. That way you can
300
+ /// make sure to take ownership properly of the file descriptors passed
301
+ /// down, if any.
302
+ ///
303
+ /// It is ok to call this function any number of times.
302
304
pub unsafe fn from_env ( ) -> Option < Client > {
303
305
Self :: from_env_ext ( false ) . client . ok ( )
304
306
}
0 commit comments