I have erlang application. In this application i run process with spawn(?MODULE, my_foo, [my_param1, my_param2, my_param3]).
And my_foo:
my_foo(my_param1, my_param2, my_param3) ->
...
some code here
...
ok.
When i open etop i see that this my_foo/3 function status: proc_lib:sync_wait/2
Than i try to put exit(self(), normal) in the end of my function, but i see same behavior: proc_lib:sync_wait/2 in etop.
How can i kill or exit process correctly?
Thank you.
Note that
exit(Pid, Reason)andexit(Reason)do NOT do the same thing ifPidis the process itself.exit/1tells the current process to exit – from the inside if you like – whileexit/2sends an exit signal to the process, even if the process is itself. So when you doexit(self(), normal)you are actually sending thenormalexit signal to yourself, which is ignored.In this case putting the
exitcall at the end of the function should not make any difference as the process automatically dies (with reasonnormal) when the function with which it was started ends. It seems like the process is suspended somewhere before that.proc_lib:sync_wait/2is called insideproc_lib:start/start_linkand sits and waits for the spawned process to doproc_lib:init_ack/1/2to return the return value for start. It would appear that your process does not callinit_ack.