Inconsistent error message from `is_process_alive`
Closed this issue · 3 comments
nathanl commented
Describe the bug
is_process_alive/1
can raise the error "not a pid" for a value for which is_pid/1
returns true
.
This happens when the pid is not local.
To Reproduce
- Start two nodes:
erl -sname one@localhost -setcookie hello
and
erl -sname two@localhost -setcookie hello
- Spawn a process on the other node to get a valid remote pid.
(one@localhost)1> Pid = spawn('two@localhost', fun() -> 'hi' end).
<10531.109.0>
- Attempt to work with that pid.
(one@localhost)2> is_pid(Pid).
true
(one@localhost)3> is_process_alive(Pid).
** exception error: bad argument
in function is_process_alive/1
called as is_process_alive(<10531.109.0>)
*** argument 1: not a pid
Expected behavior
The error message should say "not a local pid", or "is a remote pid", or something else that explains why it's not possible to check whether it's alive. "not a pid" is untrue and is inconsistent with the return value from is_pid/1
.
Affected versions
Tested with OTP 27.0
garazdawi commented
The code that prints that value is located here. A PR improving it would be most welcome!
juhlig commented
Somewhat related, I noticed many wrong error messages in io:format
and friends lately, I'll open a separate ticket for those.
garazdawi commented
Fix merged for release in 27.1