lisa
lisa copied to clipboard
Method for signals other than SIGKILL
Some programs like to be killed with SIGINT rather than SIGKILL, it would be nice to be able to send signals other than kill for some async programs.
@mcgov Thank you for suggestions. LISA use below logic to send kill signal. Can you explain more on the suggestions?
There are several things to be considered. The built-in signal constants depends installed Python package. So the signal.SIGTERM here, may be not what want to run remotely. For example, the local is Windows, the remote is Linux. We cannot send SIGTERM to remote. We have to send the hard coded number "9" to remote.
def kill(self) -> None:
if self._process:
if self._shell.is_remote:
# Support remote Posix so far
self._process.send_signal(9)
else:
# local process should use the compiled value
# the value is different between windows and posix
self._process.send_signal(signal.SIGTERM)
The specific instance I ran into was a program where you want to kill it by sending INT instead of KILL. KILL just kills it, INT prints some nice statistics and then kills it. I don't think we need to necessarily use the python signal.
The INT may not be handled correctly by the target process, so the kill may not be effective. The KILL makes sure the process is ended immediately. Another idea is to implement a tool call kill, it can specify which signal to send, and fit to more scenarios. For kill, a graceful way is to send INT firstly, if it's timeout in one or two seconds, then send KILL. Would you like to create the Kill tool?
That's true, wrapping kill or killall in a tool would fit the use case
I can create those :)
this was implemented in the kill tool, closing