gpt4 book ai didi

erlang - iex 中断菜单中有什么 (k)ill 用途?

转载 作者:行者123 更新时间:2023-12-02 19:57:38 29 4
gpt4 key购买 nike

我通过按 CTRL + C 访问 eix 1.8.2 的 Break 菜单。它看起来像这样:

BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution

起初我以为kill与abort类似(即只是结束 session ),但事实并非如此。相反,按 k 会生成核心转储并提供更多选项:

iex(1)> 
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
k


Process Information

--------------------------------------------------
=proc:<0.105.0>
State: Waiting
Spawned as: erlang:apply/2
Spawned by: <0.75.0>
Message queue length: 0
Number of heap fragments: 1
Heap fragment data: 5
Link list: [{to,<0.64.0>,#Ref<0.720592203.270008322.27074>}]
Reductions: 4202
Stack+heap: 233
OldHeap: 0
Heap unused: 177
OldHeap unused: 0
BinVHeap: 1
OldBinVHeap: 0
BinVHeap unused: 46421
OldBinVHeap unused: 46422
Memory: 2804
Stack dump:
Program counter: 0x000000001f8230e0 (io:execute_request/2 + 200)
CP: 0x0000000000000000 (invalid)
arity = 0

0x000000001ddcee08 Return addr 0x000000001f8a4ba0 ('Elixir.IEx.Server':io_get/3 + 96)
y(0) #Ref<0.720592203.270008322.27074>
y(1) {false,{get_line,unicode,<<"iex(1)> ">>}}
y(2) <0.64.0>

0x000000001ddcee28 Return addr 0x000000001d53ecf8 (<terminate process normally>)
y(0) <0.105.0>
y(1) <0.75.0>
Internal State: ACT_PRIO_NORMAL | USR_PRIO_NORMAL | PRQ_PRIO_NORMAL
(k)ill (n)ext (r)eturn:

如果我再次按 k,我会得到另一个核心转储。按 n 也会给我一个核心转储,我认为这与按 k 相同。最后一个选项 r 根据我之前所做的操作执行不同的操作。如果我只按 k 或 n 几次,它就会忽略它,我必须按 Enter 两次。 iex 像平常一样解释第二个输入并返回nil

(k)ill (n)ext (r)eturn:
r

nil

如果我多次按 k 和 n,它会执行以下操作:

(k)ill (n)ext (r)eturn:
r
** (EXIT from #PID<0.104.0>) shell process exited with reason: killed

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
09:39:57.929 [info] Application iex exited: killed

或者这个:

(k)ill (n)ext (r)eturn:
r

09:46:20.268 [info] Application iex exited: killed

09:46:20.269 [info] Application elixir exited: killed

09:46:20.274 [error] GenServer IEx.Pry terminating
** (stop) killed
Last message: {:EXIT, #PID<0.88.0>, :killed}
State: 1

或者这个:

(k)ill (n)ext (r)eturn:
r
Logger - error: {removed_failing_handler,'Elixir.Logger'}
Logger - error: {removed_failing_handler,'Elixir.Logger'}
Logger - error: {removed_failing_handler,'Elixir.Logger'}

我不确定它如何决定应显示哪些消息。

我真的很好奇 (k)ill 及其子选项的作用,并期待了解它。任何方向表示赞赏,谢谢!

最佳答案

查看source code :

case 'k':
process_killer();

switch(j) {
case 'k':
ASSERT(erts_init_process_id != ERTS_INVALID_PID);
/* Send a 'kill' exit signal from init process */
erts_proc_sig_send_exit(NULL, erts_init_process_id,
rp->common.id, am_kill, NIL,
0);
case 'n': br = 1; break;
case 'r': return;
default: return;
}

k 似乎是通过向单个进程发送终止信号来枚举和终止它们。不同的输出是因为它取决于每个进程如何处理信号。

关于erlang - iex 中断菜单中有什么 (k)ill 用途?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56688664/

29 4 0