@@ -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 ( )
@@ -293,6 +282,19 @@ impl Client {
293
282
/// environment.
294
283
///
295
284
/// 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.
296
298
pub unsafe fn from_env ( ) -> Option < Client > {
297
299
Self :: from_env_ext ( false ) . client . ok ( )
298
300
}
0 commit comments