# \#unix

**URL:** https://discuss.ocaml.org/tag/unix/58.md

[Latest](https://discuss.ocaml.org/latest.md) · [Categories](https://discuss.ocaml.org/categories.md) · [Tags](https://discuss.ocaml.org/tags.md)

---

## [Translating Rust design architecture to OCaml](https://discuss.ocaml.org/t/translating-rust-design-architecture-to-ocaml/18389)

<div class="topic-metadata">

**Author:** [@710Randy](https://discuss.ocaml.org/u/710Randy)\
**Replies:** 2\
**Last updated:** [July 26, 2026, 8:24pm UTC](https://discuss.ocaml.org/t/translating-rust-design-architecture-to-ocaml/18389 "2026-07-26T20:24:10Z")

</div>

I have been trying to make modern Linux tools with OCaml, and one idea that came to mind is the Rust community’s Uutils project. It’s well developed, and specifically, I want to adapt parts of the shadow library to make …

---

## [Idiomatic calling other process with stdin, stdout, stderr stdlib](https://discuss.ocaml.org/t/idiomatic-calling-other-process-with-stdin-stdout-stderr-stdlib/17891)

<div class="topic-metadata">

**Author:** [@removewingman](https://discuss.ocaml.org/u/removewingman)\
**Replies:** 4\
**Last updated:** [March 13, 2026, 3:39pm UTC](https://discuss.ocaml.org/t/idiomatic-calling-other-process-with-stdin-stdout-stderr-stdlib/17891 "2026-03-13T15:39:08Z")

</div>

Hello, I want to call a process and provide stdin, get stdout and if something goes wrong exit and print stderr with stdlib. Can anyone give me feedback if this is the most idiomatic way to do this: open Unix let cmd…

---

## [\[ANN\] Serialport - new serial communication library](https://discuss.ocaml.org/t/ann-serialport-new-serial-communication-library/17594)

<div class="topic-metadata">

**Author:** [@dx3mod](https://discuss.ocaml.org/u/dx3mod)\
**Replies:** 2\
**Last updated:** [February 19, 2026, 10:32pm UTC](https://discuss.ocaml.org/t/ann-serialport-new-serial-communication-library/17594 "2026-02-19T22:32:36Z")

</div>

Hi there! I’m happy to announce the first release of the serialport library. The library is planned to be a cross-platform library for serial port communication in OCaml, which supports both POSIX and Windows systems. I…

---

## [Using package postgresql and waiting for a notify](https://discuss.ocaml.org/t/using-package-postgresql-and-waiting-for-a-notify/17780)

<div class="topic-metadata">

**Author:** [@jbe](https://discuss.ocaml.org/u/jbe)\
**Replies:** 3\
**Last updated:** [February 7, 2026, 9:40am UTC](https://discuss.ocaml.org/t/using-package-postgresql-and-waiting-for-a-notify/17780 "2026-02-07T09:40:06Z")

</div>

I’m using the postgresql package and would like to wait for a NOTIFY without repeatedly polling. The connection class provides the methods #consume\_input and #socket which could be used in a loop with Unix.select. This …

---

## [Waiting in Eio for socket data without reading it](https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615)

<div class="topic-metadata">

**Author:** [@vog](https://discuss.ocaml.org/u/vog)\
**Replies:** 1\
**Last updated:** [December 20, 2025, 2:35pm UTC](https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615 "2025-12-20T14:35:11Z")

</div>

I’d like to wrap a C library for use within Eio code. That library opens a network connection on its own, but I’m able to fetch the file descriptor of the open socket. It even operates in non-blocking mode. But how do I…

---

## [Streaming output from a program with Eio](https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560)

<div class="topic-metadata">

**Author:** [@MarcCoquand](https://discuss.ocaml.org/u/MarcCoquand)\
**Replies:** 1\
**Last updated:** [December 4, 2025, 11:29am UTC](https://discuss.ocaml.org/t/streaming-output-from-a-program-with-eio/17560 "2025-12-04T11:29:58Z")

</div>

Hey I’m trying to understand if this is possible. I’d like to open a new unix process, and stream the output using Seq, but I can’t really figure out the correct incantation. This is what I’ve tried so far Eio\_main.r…

---

## [\[ANN\] crypt 2.0 - unix crypt function](https://discuss.ocaml.org/t/ann-crypt-2-0-unix-crypt-function/17485)

<div class="topic-metadata">

**Author:** [@dx3mod](https://discuss.ocaml.org/u/dx3mod)\
**Replies:** 1\
**Last updated:** [November 21, 2025, 11:57am UTC](https://discuss.ocaml.org/t/ann-crypt-2-0-unix-crypt-function/17485 "2025-11-21T11:57:40Z")

</div>

Hi there! I’m happy to announce the release of a new major version (i.e., 2.0) of the crypt library (bindings to the Unix crypt function). The previous version, 1.3, was outdated, since the last commit was six years ago…

---

## [Fork in a Lwt framework](https://discuss.ocaml.org/t/fork-in-a-lwt-framework/17174)

<div class="topic-metadata">

**Author:** [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Replies:** 3\
**Last updated:** [August 30, 2025, 11:29am UTC](https://discuss.ocaml.org/t/fork-in-a-lwt-framework/17174 "2025-08-30T11:29:41Z")

</div>

I plan to execute a command in a subprocess from a Lwt Framework (Dream). I guess, all Unix syscall (fork, pipe…) from the current (father) process should be done from Lwt\_unix module, and the Unix syscall from the chil…

---

## [Eio Unix.EADDRNOTAVAIL on socket bind!?](https://discuss.ocaml.org/t/eio-unix-eaddrnotavail-on-socket-bind/15809)

<div class="topic-metadata">

**Author:** [@H-ANSEN](https://discuss.ocaml.org/u/H-ANSEN)\
**Replies:** 11\
**Last updated:** [December 18, 2024, 7:24pm UTC](https://discuss.ocaml.org/t/eio-unix-eaddrnotavail-on-socket-bind/15809 "2024-12-18T19:24:08Z")

</div>

Hello all! I was having some issues when making use of the Eio library, specifically when attempting to create a UDP socket and sending data. As a proof of concept, I went ahead and wrote out the Unix code by hand to try…

---

## [Unix sockets on Windows and Node.js](https://discuss.ocaml.org/t/unix-sockets-on-windows-and-node-js/15775)

<div class="topic-metadata">

**Author:** [@amaro](https://discuss.ocaml.org/u/amaro)\
**Replies:** 1\
**Last updated:** [December 11, 2024, 6:30am UTC](https://discuss.ocaml.org/t/unix-sockets-on-windows-and-node-js/15775 "2024-12-11T06:30:33Z")

</div>

I have a Node.js application using Unix sockets which works on Linux, but I’m trying to make it work on Windows. My socket has a name similar to C:\\PathTo\\socket.sock. The following code seems to work: let addr = "C:\\\\…

---

## [EINTR and SA\_RESTART support in the OCaml runtime](https://discuss.ocaml.org/t/eintr-and-sa-restart-support-in-the-ocaml-runtime/15243)

<div class="topic-metadata">

**Author:** [@edwin](https://discuss.ocaml.org/u/edwin)\
**Replies:** 4\
**Last updated:** [September 7, 2024, 12:55pm UTC](https://discuss.ocaml.org/t/eintr-and-sa-restart-support-in-the-ocaml-runtime/15243 "2024-09-07T12:55:02Z")

</div>

A signal can be handled in 2 ways after its handler has finished: return EINTR from the system call that got interrupted. This is the default behaviour automatically restart the system call, if the handler was registe…

---

## [Detect use-after-close of Unix file descriptors](https://discuss.ocaml.org/t/detect-use-after-close-of-unix-file-descriptors/13766)

<div class="topic-metadata">

**Author:** [@lindig](https://discuss.ocaml.org/u/lindig)\
**Replies:** 9\
**Last updated:** [January 8, 2024, 2:54pm UTC](https://discuss.ocaml.org/t/detect-use-after-close-of-unix-file-descriptors/13766 "2024-01-08T14:54:43Z")

</div>

On POSIX systems file descriptors (FD) are eagerly re-used. As a consequence, use-after-close of a file descriptor is often not detected and in fact harmful because it will manipulate a different file: (\* ocamlc -I +u…

---

## [\`Unix.sleep\` on windows box?](https://discuss.ocaml.org/t/unix-sleep-on-windows-box/13786)

<div class="topic-metadata">

**Author:** [@NAlec](https://discuss.ocaml.org/u/NAlec)\
**Replies:** 7\
**Last updated:** [January 4, 2024, 10:55pm UTC](https://discuss.ocaml.org/t/unix-sleep-on-windows-box/13786 "2024-01-04T22:55:03Z")

</div>

Testing the ANSITerminal library and trying to build a progress bar, I am trying to slow down a bit the progression of the bar in order to emulate an heavy process with the sleep command. It does not work at all. Compila…

---

## [This is my first OCaml program. Advices for improvement?](https://discuss.ocaml.org/t/this-is-my-first-ocaml-program-advices-for-improvement/11739)

<div class="topic-metadata">

**Author:** [@anzhi0708](https://discuss.ocaml.org/u/anzhi0708)\
**Replies:** 3\
**Last updated:** [March 21, 2023, 5:48pm UTC](https://discuss.ocaml.org/t/this-is-my-first-ocaml-program-advices-for-improvement/11739 "2023-03-21T17:48:13Z")

</div>

So it removes '\\n’s from clipboard buffer, so I can paste the content to any translation software later. If I don’t remove the NEWLINEs, the translator softwares could give me wrong translations let () = print\_endline "…

---

## [How to safely integrate and modernize bash programs and functions in OCaml programs?](https://discuss.ocaml.org/t/how-to-safely-integrate-and-modernize-bash-programs-and-functions-in-ocaml-programs/11712)

<div class="topic-metadata">

**Author:** [@Luc\_ML](https://discuss.ocaml.org/u/Luc_ML)\
**Replies:** 0\
**Last updated:** [March 20, 2023, 2:45am UTC](https://discuss.ocaml.org/t/how-to-safely-integrate-and-modernize-bash-programs-and-functions-in-ocaml-programs/11712 "2023-03-20T02:45:09Z")

</div>

I have a bunch of programs in bash using all related commands (awk, sed, grep, find, rsync, tar, zip, etc.). They are structured with functions. They have been working for a while but I don’t know exactly when, how and w…

---

## [Unix.symlink and Unix.stat](https://discuss.ocaml.org/t/unix-symlink-and-unix-stat/11310)

<div class="topic-metadata">

**Author:** [@mro](https://discuss.ocaml.org/u/mro)\
**Replies:** 1\
**Last updated:** [February 4, 2023, 8:32pm UTC](https://discuss.ocaml.org/t/unix-symlink-and-unix-stat/11310 "2023-02-04T20:32:05Z")

</div>

A newly created symlink seems to be of type Unix.S\_REG, not Unix.S\_LNK? I am on $ opam switch show 4.10.0+musl+static+flambda $ uname -sm Linux x86\_64 and do utop # Unix.symlink "../etc/passwd" "/tmp/passwd";; - : un…

---

## [How to implement a system call?](https://discuss.ocaml.org/t/how-to-implement-a-system-call/10273)

<div class="topic-metadata">

**Author:** [@vdolgov](https://discuss.ocaml.org/u/vdolgov)\
**Replies:** 3\
**Last updated:** [August 7, 2022, 12:11pm UTC](https://discuss.ocaml.org/t/how-to-implement-a-system-call/10273 "2022-08-07T12:11:28Z")

</div>

Hi everybody! :wave: I’m trying to figure out how to make a system call which is not present in Unix module. Suppose I need shm\_open to access the shared memory, what is the general flow of implementing such thing? It w…

---

## [Lwt: Best way to redirect the output of one command to a file / another command](https://discuss.ocaml.org/t/lwt-best-way-to-redirect-the-output-of-one-command-to-a-file-another-command/9745)

<div class="topic-metadata">

**Author:** [@ahem](https://discuss.ocaml.org/u/ahem)\
**Replies:** 1\
**Last updated:** [April 29, 2022, 3:55am UTC](https://discuss.ocaml.org/t/lwt-best-way-to-redirect-the-output-of-one-command-to-a-file-another-command/9745 "2022-04-29T03:55:43Z")

</div>

Hello, I experimented with different ways of replicating the unix command cat infile \> outfile, for a large-ish file (~1 GB), using Lwt\_io, Lwt\_process, Lwt\_stream modules. I am only using cat here as a simplification fo…

---

## [Leaking processes](https://discuss.ocaml.org/t/leaking-processes/9339)

<div class="topic-metadata">

**Author:** [@Jon\_Harrop](https://discuss.ocaml.org/u/Jon_Harrop)\
**Replies:** 7\
**Last updated:** [February 16, 2022, 8:21pm UTC](https://discuss.ocaml.org/t/leaking-processes/9339 "2022-02-16T20:21:12Z")

</div>

I’m trying to write a concurrent web crawler (of sorts) in OCaml, delegating downloading to wget invoked via Unix.open\_process\_in but the processes are leaked until an invocation dies with EAGAIN. This program repros the…

---

## [Unset environment variable](https://discuss.ocaml.org/t/unset-environment-variable/9025)

<div class="topic-metadata">

**Author:** [@vdolgov](https://discuss.ocaml.org/u/vdolgov)\
**Replies:** 6\
**Last updated:** [December 22, 2021, 6:34pm UTC](https://discuss.ocaml.org/t/unset-environment-variable/9025 "2021-12-22T18:34:08Z")

</div>

Hello, everybody :wave: Is it possible somehow to unset (remove) environment variable after it was set with Unix.putenv? Maybe I miss something, but I do not see any suitable function for this task in Stdlib :frowning:

---

## [Tooling/linker issue in FreeBSD](https://discuss.ocaml.org/t/tooling-linker-issue-in-freebsd/8837)

<div class="topic-metadata">

**Author:** [@daachi](https://discuss.ocaml.org/u/daachi)\
**Replies:** 4\
**Last updated:** [November 18, 2021, 10:54am UTC](https://discuss.ocaml.org/t/tooling-linker-issue-in-freebsd/8837 "2021-11-18T10:54:38Z")

</div>

First of all, I am new to OCaml so apologies in advance if I’ve missed something terribly obvious. I am super excited to be able to work on OCaml and FreeBSD! I also acknowledge this is a FreeBSD specific topic but I’ve…

---

## [Fork fails with "Cannot allocate memory" despite lots of memory](https://discuss.ocaml.org/t/fork-fails-with-cannot-allocate-memory-despite-lots-of-memory/1280)

<div class="topic-metadata">

**Author:** [@smolkaj](https://discuss.ocaml.org/u/smolkaj)\
**Replies:** 15\
**Last updated:** [May 31, 2019, 2:00pm UTC](https://discuss.ocaml.org/t/fork-fails-with-cannot-allocate-memory-despite-lots-of-memory/1280 "2019-05-31T14:00:22Z")

</div>

I’m having issues with Unix.fork (). It fails reliably with Uncaught exception: (Unix.Unix\_error "Cannot allocate memory" fork "") even though OCaml is using less than 1 GB of memory when fork is called and there …

---

## [How to get the actual sockaddr bound by \`Unix.(bind (INET\_ADDR (inet\_addr\_any, 0)))\`?](https://discuss.ocaml.org/t/how-to-get-the-actual-sockaddr-bound-by-unix-bind-inet-addr-inet-addr-any-0/455)

<div class="topic-metadata">

**Author:** [@hackwaly](https://discuss.ocaml.org/u/hackwaly)\
**Replies:** 7\
**Last updated:** [November 21, 2018, 8:59am UTC](https://discuss.ocaml.org/t/how-to-get-the-actual-sockaddr-bound-by-unix-bind-inet-addr-inet-addr-any-0/455 "2018-11-21T08:59:42Z")

</div>

How to get the actual sockaddr bound by Unix.(bind (INET\_ADDR (inet\_addr\_any, 0))) ? Or Lwt\_io.establish\_server? I want to let system to choose a unused port, and get the port number to tell the client to connect.

---

## [\[solved\] Unix file handling bindings](https://discuss.ocaml.org/t/solved-unix-file-handling-bindings/2049)

<div class="topic-metadata">

**Author:** [@cfcs](https://discuss.ocaml.org/u/cfcs)\
**Replies:** 10\
**Last updated:** [June 1, 2018, 10:13pm UTC](https://discuss.ocaml.org/t/solved-unix-file-handling-bindings/2049 "2018-06-01T22:13:55Z")

</div>

Hi, I’m trying to write a program that deals with sparse files, and works on 32-bit platforms, but I’m running into some issues with the Unix module from the standard library: Unix.ftruncate and Unix.lseek take an int a…

---

## [Documentation for unix-base and vi line-editing in Ocaml shell](https://discuss.ocaml.org/t/documentation-for-unix-base-and-vi-line-editing-in-ocaml-shell/1786)

<div class="topic-metadata">

**Author:** [@psacawa](https://discuss.ocaml.org/u/psacawa)\
**Replies:** 3\
**Last updated:** [March 28, 2018, 11:51am UTC](https://discuss.ocaml.org/t/documentation-for-unix-base-and-vi-line-editing-in-ocaml-shell/1786 "2018-03-28T11:51:51Z")

</div>

Hi all, I have two-ish questions, I’d like to know how to view the documentation of unix system API for the package unix-base. I generated documentation with odig odoc, but somehow unix-base docs did not appear? My hop…

---

## [Unix.open\_process does not expose pid of child](https://discuss.ocaml.org/t/unix-open-process-does-not-expose-pid-of-child/1112)

<div class="topic-metadata">

**Author:** [@smolkaj](https://discuss.ocaml.org/u/smolkaj)\
**Replies:** 1\
**Last updated:** [November 13, 2017, 6:04pm UTC](https://discuss.ocaml.org/t/unix-open-process-does-not-expose-pid-of-child/1112 "2017-11-13T18:04:25Z")

</div>

I need to run a process in parallel with OCaml. Unix.open\_process provides a nice high-level API for doing so, but unfortunately it does not expose the PID of the forked child process: I am wondering if there is a de…

---

## [System calls, Unix.close, signals, EINTR](https://discuss.ocaml.org/t/system-calls-unix-close-signals-eintr/972)

<div class="topic-metadata">

**Author:** [@thomas\_ridge](https://discuss.ocaml.org/u/thomas_ridge)\
**Replies:** 21\
**Last updated:** [October 17, 2017, 2:53pm UTC](https://discuss.ocaml.org/t/system-calls-unix-close-signals-eintr/972 "2017-10-17T14:53:53Z")

</div>

Hi, For a long time I wondered about signals. Essentially, I would like to program without having to think about them at all. For example, POSIX says that close can fail with EBADF (which I am happy to handle) and EINT…

---

## [Sending UDP on macOS fails](https://discuss.ocaml.org/t/sending-udp-on-macos-fails/636)

<div class="topic-metadata">

**Author:** [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Replies:** 7\
**Last updated:** [July 31, 2017, 10:50pm UTC](https://discuss.ocaml.org/t/sending-udp-on-macos-fails/636 "2017-07-31T22:50:27Z")

</div>

Hi, I’m trying to send an UDP packet using Async: (\* corebuild -pkg async sendudp.native \*) open Core.Std open Async.Std let buf = "hello world\\n" |\> Iobuf.of\_string |\> Iobuf.read\_only let addr = Unix.Inet\_addr.o…

---

## [Bind only to localhost in Cohttp\_lwt\_unix?](https://discuss.ocaml.org/t/bind-only-to-localhost-in-cohttp-lwt-unix/574)

<div class="topic-metadata">

**Author:** [@sgrove](https://discuss.ocaml.org/u/sgrove)\
**Replies:** 2\
**Last updated:** [July 20, 2017, 9:27am UTC](https://discuss.ocaml.org/t/bind-only-to-localhost-in-cohttp-lwt-unix/574 "2017-07-20T09:27:18Z")

</div>

My code seems to bind to 0.0.0.0 - is there a way to specify I only want to bind to localhost/127.0.0.1? C.Server.create mode::(TCP (Port 8082)) (C.Server.make callback::server ()) |\> Lwt\_main.run

---

## [Lwt\_unix.read from a large file and scheduling](https://discuss.ocaml.org/t/lwt-unix-read-from-a-large-file-and-scheduling/513)

<div class="topic-metadata">

**Author:** [@fpoling](https://discuss.ocaml.org/u/fpoling)\
**Replies:** 5\
**Last updated:** [July 7, 2017, 4:13pm UTC](https://discuss.ocaml.org/t/lwt-unix-read-from-a-large-file-and-scheduling/513 "2017-07-07T16:13:49Z")

</div>

Hi, From an LWT documentation I got an impression that the library always tried try to do as much work as possible. Essentially scheduling only happens when things block. As on Linux reading from a file never blocks, I …

[Next page](https://discuss.ocaml.org/tag/unix/58.md?match_all_tags=true&page=1&tags%5B%5D=unix)
