Exile - NIF based alternative to ports for running external programs. Provides back-pressure using non-blocking io

Pushed changes to use new approach

New approach

  • exec spawner shim using port, we are no longer using NIF for this
  • exchange stdin and stdout fd from shim to exile using unix domain socket (thanks to new socket API)
  • spawner shim then exec specified binary
  • communicates with os process using NIF like before

Advantages over old approach

  • exec code is simpler and slightly safer now, since we no longer need NIF for exec
  • works with OTP-23 (but now minimum requirement is OTP-22.1)
  • does not require polling for capturing process exit status

For more details please check: New approach to exec external process by akash-akya · Pull Request #8 · akash-akya/exile · GitHub

6 Likes

What’s the recommended way of handing stderr?

For instance, the following sends the text “/usr/bin/cat: foobar: No such file or directory” to the console STDOUT:

Exile.stream!(["cat", "non-existent-file.txt"])
|> Stream.into(File.stream!("temp.txt"))
|> Stream.run()

However, I would like to be able to capture stderr somehow, while still streaming contents to the other file.

Is there a way of doing this with Exile?

Hi @jdcosta, welcome to elixirforum.

Currently stderr is not handled and the spawned process will directly write to console.
It is pending from sometime now, I will add support for stderr sometime soon.

2 Likes

Got it, thanks!

Hi @akash-akya :wave:t2:. Thanks for building this library! Last year I built a little toy server for serving up on-demand video thumbnails via FFMPEG + Exile and it seemed to work without a hitch.

I’m wondering what the status of the library is? I’m curious if you’d consider it “production ready” at this point. Cheers!

Hi @bismark, I am happy that you are finding it useful!

Regarding production readiness, I think the overall solution is stable enough to be called “ready” and there is no plan (or need) for any big change at the moment, only some minor enhancements. So I will update the documentation and push to hex.pm. Thanks for reminding!

1 Like