vonH
How do I kill a process ` #PID<0.186.0` in iex?
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cursor to recall the previoius commands. But how do I kill the Plug process to restart it after I recompile.
Is there some command I can use to kill #PID<0.186.0 which I assume if the plug’s process?
Erlang/OTP 19 [erts-8.3] [source-d5c06c6] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (1.4.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> c "myfuncs/funcs_router.ex"
[MyRouter]
iex(2)> {:ok, _} = Plug.Adapters.Cowboy.http MyRouter, []
{:ok, #PID<0.186.0>}
iex(3)> c "myfuncs/funcs_router.ex"
...
[MyRouter]
iex(4)> {:ok, _} = Plug.Adapters.Cowboy.http MyRouter, []
** (MatchError) no match of right hand side value: {:error, {:already_started, #PID<0.186.0>}}
Most Liked
kelvinst
@cmkarlsson is right in his answer, but making it short:
Process.exit(pid, :normal) == please stop my dear process ![]()
![]()
Process.exit(pid, :kill) == ![]()
![]()
Important: it’s not a threat to kill, it’s killing! So the process has no option to exit gracefully, it just stops processing whatever it was processing and has no time to do the exit routine it has.
cmkarlsson
It is used when a process traps exists. Then the :normal message is transformed into an {:'EXIT', from, :normal} message which is delivered to the message queue of the process and it can choose to exit itself when it receives it. But if the process is not trapping exists nothing happens. This is different from :kill and reason explained below.
You can send any exit reason to the process. :kill and :normal are special. Any other reason has the following behaviour:
- If process is not trapping exists it will exit with
reason - If process is trapping exists the signal is transformed to
{:'EXIT', from, reason}and deliver to the message queue
:kill is an untrappable exit and the process will be killed.
(Mostly stolen from h(Process.exit))
grych
Process.exit(pid("0.186.0"), :normal)







