Send kill signal from javascript

Hi all:

I need to send a KILL signal to a process using GLib and Javascript, but I’m unable to find how to do it. In C and Vala I can use the Posix calls, but AFAIK, they aren’t available in Javascript. I even tried to do it using “brute force”, with spawn_sync() passing “/bin/kill” and the pid, but I receive an odd message: if I try to kill the pid 7243, I receive:

`kill: "7243" is not supported`

Can someone help me?


There doesn’t seem to be anything like an os module for gjs, so I guess /bin/kill is your best option. How are you executing it exactly? In the interpreter, this works as expected:

GLib.spawn_sync(null, ['/bin/kill', pid], null, 0, null);

And so does:

let proc = new Gio.Subprocess({argv: ['/bin/kill', pid]});

This is odd… with spawn_sync didn’t work, but with Gio.Subprocess, it does work…