ambrevar/shell: Rename kill to system-signal, add kill, term.
parent
f55db510e7
commit
ffa4c799f7
|
@ -181,18 +181,27 @@ Return the first non-deleted directory."
|
|||
(uiop:ensure-all-directories-exist (list (uiop:ensure-directory-pathname path)))
|
||||
path)
|
||||
|
||||
(defun kill (pids &key (signal 'term) options)
|
||||
(defun system-signal (pid-or-pids &key (signal 'term) options)
|
||||
"OPTIONS are PKILL options."
|
||||
;; TODO: Is it possible to kill a group without pkill, maybe with osicat?
|
||||
(uiop:run-program
|
||||
(append
|
||||
(list (if options "pkill" "kill") (format nil "-~a" signal))
|
||||
options
|
||||
(mapcar #'princ-to-string pids))))
|
||||
(mapcar #'princ-to-string (alex:ensure-list pid-or-pids)))))
|
||||
|
||||
(defun kill (pid-or-pids)
|
||||
"Kill PID-OR-PIDS (with SIGKILL)."
|
||||
(system-signal pid-or-pids :signal 'kill))
|
||||
|
||||
(defun term (pid-or-pids)
|
||||
"Cleanly terminate PID-OR-PIDS."
|
||||
(system-signal pid-or-pids :signal 'term))
|
||||
|
||||
(defun terminate-process-with-group (process-info)
|
||||
(when (uiop:process-alive-p process-info)
|
||||
(kill (list (format nil "~a" (osicat-posix:getpgid (uiop:process-info-pid process-info))))
|
||||
(system-signal
|
||||
(list (format nil "~a" (osicat-posix:getpgid (uiop:process-info-pid process-info))))
|
||||
:signal 'term ;TODO: -KILL instead?
|
||||
:options '("-g"))
|
||||
(uiop:terminate-process process-info)))
|
||||
|
|
Loading…
Reference in New Issue