@@ -211,7 +211,16 @@ val fork : unit -> int
211211 - None of the above is necessary if you intend to call [exec]. Indeed, in
212212 that case, it is not even necessary to use [Lwt_unix.fork]. You can use
213213 {!Unix.fork}.
214- - To abandon some more promises, see {!Lwt.abandon_paused}. *)
214+ - To abandon some more promises, see {!Lwt.abandon_paused}.
215+
216+ Furthermore:
217+
218+ - Calling [Lwt_unix.fork] raises an execption if [Domain.spawn] has been
219+ called at any point in the program's past.
220+ - Calling [Lwt_unix.fork] can result in the child process being in a
221+ corrupted state if any thread has been started. Lwt starts threads when
222+ [Lwt_preemptive.detach] is called. Lwt implicitly starts threads to
223+ perform blocking I/O unless the {!async_method} is set to [Async_none]. *)
215224
216225type process_status =
217226 Unix .process_status =
@@ -256,7 +265,10 @@ val system : string -> process_status Lwt.t
256265 (* * Executes the given command, waits until it terminates, and
257266 return its termination status. The string is interpreted by the
258267 shell [/bin/sh] on Unix and [cmd.exe] on Windows. The result
259- [WEXITED 127] indicates that the shell couldn't be executed. *)
268+ [WEXITED 127] indicates that the shell couldn't be executed.
269+
270+ The function uses {!fork} internally. As a result, this function is
271+ brittle. See all the warnings relating to [fork] for more details. *)
260272
261273(* * {2 Basic file input/output} *)
262274
@@ -1278,98 +1290,59 @@ val tcflow : file_descr -> flow_action -> unit Lwt.t
12781290
12791291
12801292
1281- (* * {2 Configuration (deprecated) } *)
1293+ (* * {2 Configuration} *)
12821294
12831295(* * For system calls that cannot be made asynchronously, Lwt uses one
12841296 of the following method: *)
12851297type async_method =
12861298 | Async_none
12871299 (* * System calls are made synchronously, and may block the
1288- entire program. *)
1300+ entire program.
1301+
1302+ The main use cases for this are:
1303+ - debugging (execution is simpler)
1304+ - working with fork and exec (which are not thread-safe)
1305+ - when calling specific blocking I/O which is known to be fast *)
12891306 | Async_detach
12901307 (* * System calls are made in another system thread, thus without
12911308 blocking other Lwt promises. The drawback is that it may
12921309 degrade performance in some cases.
12931310
12941311 This is the default. *)
1295- | Async_switch
1296- [@ ocaml.deprecated " Use Lwt_unix.Async_detach." ]
1297- (* * @deprecated A synonym for [Async_detach]. This was a
1298- different method in the past. *)
12991312
13001313val default_async_method : unit -> async_method
1301- [@@ ocaml.deprecated
1302- " Will always return Async_detach in Lwt >= 5.0.0. See
1303- https://github.com/ocsigen/lwt/issues/572" ]
13041314(* * Returns the default async method.
13051315
13061316 This can be initialized using the environment variable
1307- ["LWT_ASYNC_METHOD"] with possible values ["none"],
1308- ["detach"] and ["switch"].
1309-
1310- @deprecated Will always return [Async_detach] in Lwt 5.0.0. *)
1317+ ["LWT_ASYNC_METHOD"] with possible values ["none"] and
1318+ ["detach"].
1319+ *)
13111320
13121321val set_default_async_method : async_method -> unit
1313- [@@ ocaml.deprecated
1314- " Will be a no-op in Lwt >= 5.0.0. See
1315- https://github.com/ocsigen/lwt/issues/572" ]
1316- (* * Sets the default async method.
1317-
1318- @deprecated Will be a no-op in Lwt 5.0.0. *)
1322+ (* * Sets the default async method. *)
13191323
13201324val async_method : unit -> async_method
1321- [@@ ocaml.deprecated
1322- " Will always return Async_detach in Lwt >= 5.0.0. See
1323- https://github.com/ocsigen/lwt/issues/572" ]
13241325(* * [async_method ()] returns the async method used in the current
1325- thread.
1326-
1327- @deprecated Will always return [Async_detach] in Lwt 5.0.0. *)
1326+ thread. *)
13281327
13291328val async_method_key : async_method Lwt .key
1330- [@@ ocaml.deprecated
1331- " Will be ignored in Lwt >= 5.0.0. See
1332- https://github.com/ocsigen/lwt/issues/572" ]
1333- (* * The key for storing the local async method.
1334-
1335- @deprecated Will be ignored in Lwt 5.0.0. *)
1329+ (* * The key for storing the local async method. *)
13361330
13371331val with_async_none : (unit -> 'a ) -> 'a
1338- [@@ ocaml.deprecated
1339- " Will have no effect in Lwt >= 5.0.0. See
1340- https://github.com/ocsigen/lwt/issues/572" ]
13411332(* * [with_async_none f] is a shorthand for:
13421333
13431334 {[
13441335 Lwt.with_value async_method_key (Some Async_none) f
13451336 ]}
1346-
1347- @deprecated Will have no effect in Lwt 5.0.0. *)
1337+ *)
13481338
13491339val with_async_detach : (unit -> 'a ) -> 'a
1350- [@@ ocaml.deprecated
1351- " Will have no effect in Lwt >= 5.0.0. See
1352- https://github.com/ocsigen/lwt/issues/572" ]
13531340(* * [with_async_detach f] is a shorthand for:
13541341
13551342 {[
13561343 Lwt.with_value async_method_key (Some Async_detach) f
13571344 ]}
1358-
1359- @deprecated Will have no effect in Lwt 5.0.0. *)
1360-
1361- val with_async_switch : (unit -> 'a ) -> 'a
1362- [@@ ocaml.deprecated
1363- " Will have no effect in Lwt >= 5.0.0. See
1364- https://github.com/ocsigen/lwt/issues/572" ]
1365- (* * [with_async_switch f] is a shorthand for:
1366-
1367- {[
1368- Lwt.with_value async_method_key (Some Async_switch) f
1369- ]}
1370-
1371- @deprecated Will have no effect in Lwt 5.0.0. *)
1372-
1345+ *)
13731346
13741347
13751348(* * {2 Low-level interaction} *)
0 commit comments