ThreadUnix(3)
π ThreadUnix(3) π
okay so bestie, this page is from the OCaml library, and the module is ThreadUnix. it's giving old-school system-call energy, but make it thread-compatible. let's go π
β¨ NAME β¨
ThreadUnix β thread-compatible system calls. periodt.
π¦ Module
Module ThreadUnix
: sig end
π Documentation
π¨ Deprecated. The functionality of this module has been merged back into theUnixmodule. Threaded programs can now call the functions from moduleUnixdirectly, and still get the correct behavior (block the calling thread, if required, but do not block all threads in the process).
Thread-compatible system calls. slay.
π§΅ Process handling
val execv : string -> string array -> unitβ theexecvsignature, untouched and iconic. string in, string array in, unit out.val execve : string -> string array -> string array -> unitβexecvesignature with that extrastring array, no cap.val execvp : string -> string array -> unitβ theexecvpsignature, exactly as written.val wait : unit -> int * Unix.process_statusβwaitgives you back thatint * Unix.process_statuspair.val waitpid : Unix.wait_flag list -> int -> int * Unix.process_statusβwaitpidsignature:Unix.wait_flag list, then anint, then the pair.val system : string -> Unix.process_statusβsystemsignature, returningUnix.process_status.
π₯ Basic input/output
val read : Unix.file_descr -> bytes -> int -> int -> intβ thereadsignature:Unix.file_descr,bytes, twoints, and anintback.val write : Unix.file_descr -> bytes -> int -> int -> intβ thewritesignature, same shape, still returning anint.val write_substring : Unix.file_descr -> string -> int -> int -> intβwrite_substringsignature, with astringinstead ofbytes.
β±οΈ Input/output with timeout
val timed_read : Unix.file_descr -> bytes -> int -> int -> float -> intβ thetimed_readsignature, and also: SeeThreadUnix.timed_write.val timed_write : Unix.file_descr -> bytes -> int -> int -> float -> intβ Behave asThreadUnix.readandThreadUnix.write, except thatUnix_error(ETIMEDOUT,_,_)is raised if no data is available for reading or ready for writing afterdseconds. The delaydis given in the fifth argument, in seconds.val timed_write_substring : Unix.file_descr -> string -> int -> int -> float -> intβ thetimed_write_substringsignature, and also: SeeThreadUnix.timed_write.
π Polling
val select : Unix.file_descr list -> Unix.file_descr list -> Unix.file_descr list -> float -> Unix.file_descr list * Unix.file_descr list * Unix.file_descr listβ threeUnix.file_descr lists in, afloat, then threeUnix.file_descr lists back out. that's the whole shape, bestie.
π° Pipes and redirections
val pipe : ?cloexec:bool -> unit -> Unix.file_descr * Unix.file_descrβpipesignature with optional?cloexec:bool, returning a pair ofUnix.file_descrs.val open_process_in : string -> in_channelβopen_process_insignature, string in,in_channelout.val open_process_out : string -> out_channelβopen_process_outsignature, string in,out_channelout.val open_process : string -> in_channel * out_channelβopen_processsignature, returning thein_channel * out_channelpair.
β° Time
val sleep : int -> unitβsleepsignature: oneint, oneunit, that's it.
π Sockets
val socket : ?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int -> Unix.file_descrβsocketsignature, optional?cloexec:booland all.val accept : ?cloexec:bool -> Unix.file_descr -> Unix.file_descr * Unix.sockaddrβacceptsignature with optional?cloexec:bool, returningUnix.file_descr * Unix.sockaddr.val connect : Unix.file_descr -> Unix.sockaddr -> unitβconnectsignature,Unix.file_descrandUnix.sockaddrin,unitout.val recv : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> intβrecvsignature, withUnix.msg_flag listand anintback.val recvfrom : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddrβrecvfromsignature, returningint * Unix.sockaddr.val send : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> intβsendsignature, withUnix.msg_flag listand anintback.val send_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> intβsend_substringsignature, using astringand returning anint.val sendto : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> intβsendtosignature, withUnix.sockaddrand anintback.val sendto_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> intβsendto_substringsignature, string flavor,Unix.sockaddr,intback.val open_connection : Unix.sockaddr -> in_channel * out_channelβopen_connectionsignature, returningin_channel * out_channel.
that's the page, bestie β OCamldoc, 2026-09-24, ThreadUnix(3), byeee π
π¦ where this page comes from
- alpine 3.24: ocaml-doc 4.14.4-r0 Β· LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms