ssh_task_kill
Terminate a remote background process by sending a signal to its PID, with optional force-kill fallback if it doesn't exit in time.
Instructions
Terminate a background task (launched via ssh_task_launch, or any other real remote PID) by sending a signal to its PID.
If force=True and the process doesn't exit after wait_seconds, it will be forcibly killed with SIGKILL (signal 9).
With use_sudo=True on a 'linux'/'flex' connection with a BusyBox-style
ps that doesn't support -o pgid= (check ssh_conn_connect/
ssh_conn_host_info's capabilities), this raises a clear error instead
of running - there is no clean fallback, since killing just the captured
PID (rather than its whole process group) can leave the sudo'd command's
real child process(es) running as orphans, exactly the failure mode this
check exists to prevent. Not an issue with use_sudo=False.
Returns:
{'pid', 'result', 'signal', 'force_kill_used', 'timestamp'}. result is
one of:
- 'killed': confirmed terminated (by the initial signal or the force-kill
fallback - see force_kill_used to tell which). Terminal - nothing left
to check.
- 'already_exited': the process was already gone before any signal was sent.
Terminal.
- 'failed_to_kill': still running after both the signal and force-kill
attempt (or after the signal alone, if force=False). Not terminal - the
process is still alive; consider retrying or investigating why it won't die.
- 'invalid_pid': pid wasn't a valid positive integer - no signal was sent.
- 'error': the kill attempt itself failed unexpectedly (e.g. connection
issue) - the process's actual state is unknown, not necessarily still running.
`force_kill_used` is True iff the SIGKILL fallback was actually attempted
(the initial signal alone was not enough to end the process), regardless of
whether the fallback itself succeeded - False if the initial signal alone
was sufficient, the process was already gone, `pid` was invalid, or
`force=False` so no fallback was ever attempted.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Process ID to terminate | |
| force | No | Force kill with SIGKILL if process doesn't exit | |
| signal | No | Signal to send (15=TERM, 9=KILL) | |
| use_sudo | No | Use sudo for the kill operation | |
| wait_seconds | No | Seconds to wait before force kill |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||