saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
541 stars 141 forks source link

Supervised process causes shutdown_error #94

Closed seancribbs closed 7 years ago

seancribbs commented 7 years ago

Here's an example from logs of one of our tests, where we are running the collectd daemon as a subprocess:

2017-02-10 22:16:40.308 <collectd@drazil-dev> [error] <0.172.0> Supervisor 'Elixir.Drazil.Collectd.Supervisor' had child 'Elixir.Drazil.Collectd.Daemon' started with 'Elixir.Drazil.Collectd.Daemon':start_link() at <0.176.0> exit with reason {owner_died,<0.172.0>,shutdown} in context shutdown_error

We are putting the pid returned from exec:run_link into our supervision tree, so we intermittently get this error when shutting down the app. It seems this comes from https://github.com/saleyn/erlexec/blob/master/src/exec.erl#L883-L886:

    {'EXIT', Pid, Reason} ->
        % Pid died
        debug(Debug, "~w ~w got exit from linked ~w: ~p\n", [self(), OsPid, Pid, Reason]),
        exit({owner_died, Pid, Reason});

However it seems since this occurs during shutdown, this should not cause an abnormal exit, but should exit normal or shutdown according to OTP. Could this be updated to match on the Reason and exit normally?

saleyn commented 7 years ago

Yes, your proposal makes sense. I am traveling at the moment. Feel free to submit the patch and I'll merge.

saleyn commented 7 years ago

See commit d241886