You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Rodrigo Garcia <rp...@gmail.com> on 2021/05/28 04:13:23 UTC
[issue] Killing a parent pid and all its children pid all together
Hello all,
My issue is related to testing the SIGKILL in Nuttx and not making it work
correctly.
Description:
=========
I am using a ESP32 DevKitC Board using default NSH configuration.
1) Enabled CONFIG_SIG_DEFAULT=y and CONFIG_SCHED_HAVE_PARENT=y
2) After starting the board, type "sh" + <enter> 3 times. Run "ps":
nsh> sh
nsh> sh
nsh> sh
nsh> ps
PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK
COMMAND
0 0 0 FIFO Kthread N-- Ready 00000000 003072
Idle Task
1 0 100 RR Task --- Waiting Signal 00000000 002096 init
4 1 100 RR Task --- Waiting Signal 00000000 002096 sh
5 4 100 RR Task --- Waiting Signal 00000000 002096 sh
6 5 100 RR Task --- Running 00000000 002096 sh
3) kill the parent "sh" and try to run "ps"
Result is a situation where it is very hard to type any command, as seen
below:
nsh> kill -9 4
nsh> nsh>
nsh>
nsh> ps
nsh: p: command not found
nsh> sp
nsh: ss: command not found
nsh> ps
nsh: pp: command not found
nsh> ss
nsh: ss: command not found
nsh> pps
nsh: p: command not found
nsh> ps
nsh: spsp: command not found
nsh> sp
nsh: ss: command not found
nsh> sp
PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK
COMMAND
0 0 0 FIFO Kthread N-- Ready 00000000 003072
Idle Task
1 0 100 RR Task --- Ready 00000000 002096 init
5 4 100 RR Task --- Waiting Signal 00000000 002096 sh
6 5 100 RR Task --- Running 00000000 002096 sh
4) As above, none of the children were killed... and I think that init (pid
1) and sh (pid 6) are both reading the console input, generating all those
"sort of typing errors" above. I had to type "sp" to run "ps".
Question:
Do I need to set up some other option on menuconfig in order to kill the
pid of the parent and all its children all together?
Best Regards,
Rodrigo Garcia.
Re: [issue] Killing a parent pid and all its children pid all together
Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Rodrigo,
Based on your direct message on LinkedIn I think you already found it, right?
RTOS Features->
Tasks & Scheduling->
[*] Support parent/child task relationship
I think the current behavior is expected for a POSIX / Unix SO, please
take a look:
http://morningcoffee.io/killing-a-process-and-all-of-its-descendants.html
BR,
Alan
On 5/28/21, Rodrigo Garcia <rp...@gmail.com> wrote:
> Hello all,
>
> My issue is related to testing the SIGKILL in Nuttx and not making it work
> correctly.
>
> Description:
> =========
> I am using a ESP32 DevKitC Board using default NSH configuration.
>
> 1) Enabled CONFIG_SIG_DEFAULT=y and CONFIG_SCHED_HAVE_PARENT=y
> 2) After starting the board, type "sh" + <enter> 3 times. Run "ps":
>
> nsh> sh
> nsh> sh
> nsh> sh
> nsh> ps
> PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK
> COMMAND
> 0 0 0 FIFO Kthread N-- Ready 00000000 003072
> Idle Task
> 1 0 100 RR Task --- Waiting Signal 00000000 002096
> init
> 4 1 100 RR Task --- Waiting Signal 00000000 002096 sh
> 5 4 100 RR Task --- Waiting Signal 00000000 002096 sh
> 6 5 100 RR Task --- Running 00000000 002096 sh
>
> 3) kill the parent "sh" and try to run "ps"
> Result is a situation where it is very hard to type any command, as seen
> below:
>
> nsh> kill -9 4
> nsh> nsh>
> nsh>
> nsh> ps
> nsh: p: command not found
> nsh> sp
> nsh: ss: command not found
> nsh> ps
> nsh: pp: command not found
> nsh> ss
> nsh: ss: command not found
> nsh> pps
> nsh: p: command not found
> nsh> ps
> nsh: spsp: command not found
> nsh> sp
> nsh: ss: command not found
> nsh> sp
> PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK
> COMMAND
> 0 0 0 FIFO Kthread N-- Ready 00000000 003072
> Idle Task
> 1 0 100 RR Task --- Ready 00000000 002096
> init
> 5 4 100 RR Task --- Waiting Signal 00000000 002096 sh
> 6 5 100 RR Task --- Running 00000000 002096 sh
>
> 4) As above, none of the children were killed... and I think that init (pid
> 1) and sh (pid 6) are both reading the console input, generating all those
> "sort of typing errors" above. I had to type "sp" to run "ps".
>
> Question:
> Do I need to set up some other option on menuconfig in order to kill the
> pid of the parent and all its children all together?
>
> Best Regards,
> Rodrigo Garcia.
>