ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
548 stars 66 forks source link

"execve: Argument list too long" should not be a `Failure` #556

Open Innf107 opened 1 year ago

Innf107 commented 1 year ago

Currently, when passing arguments to a program with the new Eio.Process API, E2Big errors are propagated as Failure "execve: Argument list too long". Programs using this API should be able to handle such an error. In my case, I am using this in an interpreter, where I would like to attach a call trace to the exception. The current Failure exception effectively makes it impossible to do this robustly, since the error message is expected to be able to change at any point (which is not that unreasonable to expect in this case, since the current message is pretty misleading. The real error is that the total number of bytes is too large, not that there are too many arguments).

At the very least, raising a dedicated exception would prevent Warning 52: fragile constant pattern when handling the error.

talex5 commented 1 year ago

Agreed. If you want to make a PR, these lines need changing to use raise (Eio.Process.err ...).

https://github.com/ocaml-multicore/eio/blob/a6c0be9affd1793613e5e23bba4258c9f56d2c36/lib_eio_linux/low_level.ml#L524

https://github.com/ocaml-multicore/eio/blob/a6c0be9affd1793613e5e23bba4258c9f56d2c36/lib_eio_posix/low_level.ml#L288