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 the Unix module. Threaded programs can now call the functions from module Unix directly, 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 β€” the execv signature, untouched and iconic. string in, string array in, unit out.
  • val execve : string -> string array -> string array -> unit β€” execve signature with that extra string array, no cap.
  • val execvp : string -> string array -> unit β€” the execvp signature, exactly as written.
  • val wait : unit -> int * Unix.process_status β€” wait gives you back that int * Unix.process_status pair.
  • val waitpid : Unix.wait_flag list -> int -> int * Unix.process_status β€” waitpid signature: Unix.wait_flag list, then an int, then the pair.
  • val system : string -> Unix.process_status β€” system signature, returning Unix.process_status.

πŸ“₯ Basic input/output

  • val read : Unix.file_descr -> bytes -> int -> int -> int β€” the read signature: Unix.file_descr, bytes, two ints, and an int back.
  • val write : Unix.file_descr -> bytes -> int -> int -> int β€” the write signature, same shape, still returning an int.
  • val write_substring : Unix.file_descr -> string -> int -> int -> int β€” write_substring signature, with a string instead of bytes.

⏱️ Input/output with timeout

  • val timed_read : Unix.file_descr -> bytes -> int -> int -> float -> int β€” the timed_read signature, and also: See ThreadUnix.timed_write .
  • val timed_write : Unix.file_descr -> bytes -> int -> int -> float -> int β€” Behave as ThreadUnix.read and ThreadUnix.write , except that Unix_error(ETIMEDOUT,_,_) is raised if no data is available for reading or ready for writing after d seconds. The delay d is given in the fifth argument, in seconds.
  • val timed_write_substring : Unix.file_descr -> string -> int -> int -> float -> int β€” the timed_write_substring signature, and also: See ThreadUnix.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 β€” three Unix.file_descr lists in, a float, then three Unix.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 β€” pipe signature with optional ?cloexec:bool, returning a pair of Unix.file_descrs.
  • val open_process_in : string -> in_channel β€” open_process_in signature, string in, in_channel out.
  • val open_process_out : string -> out_channel β€” open_process_out signature, string in, out_channel out.
  • val open_process : string -> in_channel * out_channel β€” open_process signature, returning the in_channel * out_channel pair.

⏰ Time

  • val sleep : int -> unit β€” sleep signature: one int, one unit, that's it.

πŸ”Œ Sockets

  • val socket : ?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int -> Unix.file_descr β€” socket signature, optional ?cloexec:bool and all.
  • val accept : ?cloexec:bool -> Unix.file_descr -> Unix.file_descr * Unix.sockaddr β€” accept signature with optional ?cloexec:bool, returning Unix.file_descr * Unix.sockaddr.
  • val connect : Unix.file_descr -> Unix.sockaddr -> unit β€” connect signature, Unix.file_descr and Unix.sockaddr in, unit out.
  • val recv : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int β€” recv signature, with Unix.msg_flag list and an int back.
  • val recvfrom : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int * Unix.sockaddr β€” recvfrom signature, returning int * Unix.sockaddr.
  • val send : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int β€” send signature, with Unix.msg_flag list and an int back.
  • val send_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> int β€” send_substring signature, using a string and returning an int.
  • val sendto : Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> int β€” sendto signature, with Unix.sockaddr and an int back.
  • val sendto_substring : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> Unix.sockaddr -> int β€” sendto_substring signature, string flavor, Unix.sockaddr, int back.
  • val open_connection : Unix.sockaddr -> in_channel * out_channel β€” open_connection signature, returning in_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