(would require import signal, but it's an inbuilt package so no worries)
os.kill(pid, signal) can send a signal (signal.SIGSTOP for example) to any application. (ignore the name, it can do things other than kill)
A list of valid signals to select from can be generated with signal.valid_signals() (it produces a set of Signals, which have a value which is the number of the signal (19, 20, etc), a name which is the signal name (SIGCONT, SIGKILL, etc).
The set also includes a bunch of ints (on my PC, 35-63) that do not have any associated function, these should probably just be skipped. (64 does have a use on my PC)
for reference, all of these work (where 99 is the PID): os.kill(99, signal.SIGSTOP), os.kill(99, signal.SIGSTOP.value) and os.kill(99, 19).
these will NOT work: os.kill(99, "SIGSTOP") and os.kill(99, signal.SIGSTOP.name)
I would think a dropdown menu with every valid signal (by name, not number) and a "send" button next to it would be good.
I considered making this a seperate plugin, but it's not very complex and also fits pretty well into the functionality of this plugin.
I will try work on a PR myself (and may fail, we'll see) if you'd like, but I would prefer to hear some feedback (or if you'd like to do it) before I try.
Quick example code for getting a dictionary of signals:
import signal
valid_signals = signal.valid_signals() # returns a set of objects, not particularly useful until parsed as needed
signals = {}
for sig in valid_signals:
if hasattr(sig, "name") and hasattr(sig, "value"): # makes sure to ignore useless signals
signals[sig.name] = sig.value
print(signals) # prints {'SIGHUP': 1, 'SIGINT': 2, 'SIGQUIT': 3...
Example code for pausing an application then instantly starting it again
import signal
import os
pid = 26724 # some int
os.kill(pid, signal.SIGSTOP) # pause application
os.kill(pid, 18) # continue application
code does not work from within flatpak vscode, probably due to sandboxing
works fine otherwise
(would require
import signal, but it's an inbuilt package so no worries)os.kill(pid, signal)can send a signal (signal.SIGSTOPfor example) to any application. (ignore the name, it can do things other than kill)A list of valid signals to select from can be generated with
signal.valid_signals()(it produces a set ofSignals, which have avaluewhich is the number of the signal (19, 20, etc), anamewhich is the signal name (SIGCONT, SIGKILL, etc).The set also includes a bunch of ints (on my PC, 35-63) that do not have any associated function, these should probably just be skipped. (64 does have a use on my PC)
for reference, all of these work (where 99 is the PID):
os.kill(99, signal.SIGSTOP),os.kill(99, signal.SIGSTOP.value)andos.kill(99, 19).these will NOT work:
os.kill(99, "SIGSTOP")andos.kill(99, signal.SIGSTOP.name)I would think a dropdown menu with every valid signal (by name, not number) and a "send" button next to it would be good.
I considered making this a seperate plugin, but it's not very complex and also fits pretty well into the functionality of this plugin.
I will try work on a PR myself (and may fail, we'll see) if you'd like, but I would prefer to hear some feedback (or if you'd like to do it) before I try.
Quick example code for getting a dictionary of signals:
Example code for pausing an application then instantly starting it again
code does not work from within flatpak vscode, probably due to sandboxing
works fine otherwise