vonH

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

kelvinst

@cmkarlsson is right in his answer, but making it short:

Process.exit(pid, :normal) == please stop my dear process :pray::stop_sign:
Process.exit(pid, :kill) == :boom::gun:

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.

12
Post #9
cmkarlsson

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

grych

Creator of Drab
Process.exit(pid("0.186.0"), :normal)
OvermindDL1

OvermindDL1

:normal is a normal kill response, which most things will ignore just fine. Sending anything else is not ignored though, but traditionally :kill is sent or :brutalkill depending.

grych

grych

Creator of Drab

Well, then try to kill it instead of normal exit:

Process.exit(pid, :kill)

Where Next?

Popular in Questions Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
vonH
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 cu...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement