how to check existence of a task by pid?

15 views
Skip to first unread message

Sebastien Lorquet

unread,
Jul 12, 2022, 6:16:30 AM7/12/22
to nu...@googlegroups.com
Hi,

I have to check from a nuttx task that another task exists. I have the pid.

What is the best posix / nuttx way to "ping" a task ?

Something like

bool does_pid_exist(int pid);


Maybe kill with a specific signal that does nothing, but would fail if
the pid does not exist?

That would require me to implement this signal handler in all the tested
tasks (there would be several)

Thanks,

Sebastien

Xiang Xiao

unread,
Jul 12, 2022, 6:33:59 AM7/12/22
to NuttX
kill(pid, 0);
please reference the code here:
But you need to handle that task may exist after you get the answer.

--
This group has moved to the Apache Foundation:
http://nuttx.incubator.apache.org/community/
---
You received this message because you are subscribed to the Google Groups "NuttX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nuttx/1fb359f0-2e25-d352-615d-b55bb3500b9d%40lorquet.fr.

Sebastien Lorquet

unread,
Jul 12, 2022, 9:08:23 AM7/12/22
to nu...@googlegroups.com

Hello,

thanks, it also seems to work in nsh:

nsh> kill -0 6
nsh>
nsh> kill -0 10
nsh: kill: no such task: 10
nsh>

Sebastien

Reply all
Reply to author
Forward
0 new messages