问题描述
Process.exit(self,:normal)
可以完成工作,但是会打印出 **(退出#PID< 0.49.0> ;)正常
。
Process.exit(self, :normal)
does the job, but it prints out ** (EXIT from #PID<0.49.0>) normal
. Is there a way to exit without the message?
推荐答案
这取决于您正在运行的应用程序。如果要构建脚本,则可以调用 System.halt(0)
。如果您有应用程序,请不要调用 System.halt(0)
,因为它会关闭整个系统,而无需考虑所有其他应用程序。而是使用 System.stop(0)
。
It depends on which application you are running. If you are building a script, you can invoke System.halt(0)
. If you have an application, do not call System.halt(0)
, as it will shutdown the whole system without considering all other applications. Instead use System.stop(0)
.
或者,您可以调用 exit( :shutdown)
退出当前进程。 :shutdown
是在OTP中退出的常见原因,如果您位于 .exs
文件中,它将可以正常工作
Alternatively, you can call exit(:shutdown)
to exit the current process. :shutdown
is a common reason for exit in OTP and if you are inside .exs
files, it will work just fine too.
这篇关于如何才能从Elixir安静地退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!