node-tree-kill icon indicating copy to clipboard operation
node-tree-kill copied to clipboard

Not functional on Docker Alpine

Open Juriy opened this issue 2 years ago • 3 comments

Hello,

Trying to use this module for killing a process tree in Docker that is built on Alpine image. Unfortunately, the module fails to create a process tree, since ps does not support some of the flags that the module is relying on: --no-headers and --ppid. This results in a process returning non-zero code. Module interprets non-zero as "no child processes" and swallows the error silently.

I was trying to find a way to change the command in buildProcessTree so that it simulates the same output. Removing header is easy - we can pass the names of the columns with -o, removing the header completely:

/usr/src/app # ps -opid=""
    1
   23
   49
   67

But lack of --ppid filter support making it slightly more challenging. My Linux knowledge is not enough to tell if manually filtering by ppid in the following command would do the trick:

/usr/src/app # ps -opid="" -oppid=""
    1     0
   23     1
   49     0
   68    49

If that's the case, it would probably be the most portable version (except for the cases when ps is not present at all as described in https://github.com/pkrumins/node-tree-kill/issues/36

If there's an ambition to rewrite this part of the code, I am happy to collaborate 🙂

Juriy avatar Jan 20 '22 13:01 Juriy