Skip to content

Commit

Permalink
modules/ssh/shell (%guile-pgrep): Convert PIDs to numbers
Browse files Browse the repository at this point in the history
* modules/ssh/shell.scm (%guile-pgrep): Convert PIDs to numbers.  All callers
  updated.
  (%guile-pkill, pgrep): Update.
  • Loading branch information
artyom-poptsov committed Aug 26, 2021
1 parent 728bb9f commit 3314fc0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions modules/ssh/shell.scm
Expand Up @@ -100,13 +100,13 @@ a check result and a return code."
((eof-object? cmdline)
prev)
((and ,full? (string=? ,pattern cmdline))
(cons entry prev))
(cons (string->number entry) prev))
((string-match ,pattern cmdline)
(cons entry prev))
(cons (string->number entry) prev))
(else
prev)))
prev)))
'()
(quote ())
procs)))))

(define* (%guile-pkill session pattern
Expand All @@ -128,7 +128,7 @@ code."
(make-node session)
`(begin
(for-each (lambda (pid) (kill pid ,signal))
(quote ,(map string->number pids)))
(quote ,pids))
(quote ,pids)))))


Expand All @@ -151,9 +151,12 @@ code."
(receive (result eval-number module-name lang-name)
(%guile-pgrep session pattern #:full? full?)
(values result 0))
(rexec session (format #f "pgrep ~a '~a'"
(if full? "-f" "")
pattern))))
(receive (result exit-code)
(rexec session (format #f
"pgrep ~a '~a'"
(if full? "-f" "")
pattern))
(values (map string->number result) exit-code))))

(define* (pkill session pattern #:key
(full? #f)
Expand Down

0 comments on commit 3314fc0

Please sign in to comment.