gpt4 book ai didi

erlang - 我尝试退出,但收到一个异常错误参数,称为 exit(undefined,kill)

转载 作者:行者123 更新时间:2023-12-02 04:30:16 28 4
gpt4 key购买 nike

我正在尝试编写一个简单地杀死我的程序的函数。它被称为退出聊天。但是,当我调用函数 messenger:quitChat() 时,出现此错误。

** exception error: bad argument
in function exit/2
called as exit(undefined,kill)
in call from messenger:quitChat/0 (messenger.erl, line 26)

到目前为止我正在使用这段代码:

-module(messenger).
-export([start_server/0, server/1, logon/1, logoff/0, message/2, client/2,
requestChat/1, quitChat/0]).

server_node() ->
messenger@timberlake.

server(User_List) ->
receive
{From, logon, Name} ->
New_User_List = server_logon(From, Name, User_List),
server(New_User_List);
{From, logoff} ->
New_User_List = server_logoff(From, User_List),
server(New_User_List);
{From, message_to, To, Message} ->
server_transfer(From, To, Message, User_List),
io:format("list is now: ~p~n", [User_List]),
server(User_List)
end.

start_server() ->
register(messenger, spawn(messenger, server, [[]])).

quitChat() ->
exit(whereis(messenger), kill).

最佳答案

使用erlang:halt/0,1

Documentation

关于erlang - 我尝试退出,但收到一个异常错误参数,称为 exit(undefined,kill),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23552512/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com