0

group_leader() をローカルで登録しようとしています

register( iogl, group_leader()).

しかし、それはbad_argエラーで戻ります

** exception error: bad argument
 in function  register/2
    called as register(iogl,<0.29.0>)

group_leader() プロセスにローカルのシンボリック名を付けるにはどうすればよいですか?

を使用してグローバル名として登録できます

global:register_name(iogl, group_leader()).

しかし、それは私が必要とするものではありません。

UPD:本当の問題:

ローカル ノード ( LN )からのスポーンを使用してリモート ノード ( RN ) にプロセスを作成しますが、そのプロセスで io 操作にLNではなくRNの group_leader を使用する必要があります。ありがとうございました。

4

3 に答える 3

2

The easiest way to do this is for the code you spawn on the remote node to do:

io:format(user, FormatString, FormatArguments)

This will cause the remote code to use the remote IO group leader for output. You could also have the code you spawn remotely to set its group_leader to the pid of user shortly after it is spawned, it could then use io:format/2 normally and it will send its output to the correct place on the remote node.

I guess the short answer is that the registered(symbolic) name for the standard group leader process on any node is user.

于 2010-12-26T02:10:41.953 に答える
2

もちろん、これを登録できます。group_leader は、他の pid と同様に pid です。エラーが発生する理由は 2 つあります。

  • その名前はすでに登録されています。
  • プロセスはすでに死んでいます。group_leader プロセスが生きているかどうかはチェックされません。

そして、なぜ名前を付けたいのかという@OJの質問を繰り返します。

于 2010-12-23T04:11:01.490 に答える
1

リモートノードスポーンすると役立ちます。標準の rpc モジュールと同様に、各ノードでいくつかの spawner プロセスが必要です。

Couudant の rexi ライブラリは、そのような機能を実装しています。 https://github.com/cloudant/rexi rexi:cast/3 を参照:

rexi:cast(remote_node, self(), {io, format, ["~p~n", ["where to go the output?"]]}).
于 2010-12-24T01:40:34.257 に答える