summaryrefslogtreecommitdiff
path: root/modules/ssh/shell.scm
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-12-25 10:58:24 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-12-25 10:58:24 +0300
commitdd3f2a411d3fb6eeabb01068ea869b2fff46f568 (patch)
tree356c8f434f76f9d49009be9f4ad267438b8428cc /modules/ssh/shell.scm
parentshell.scm: Update the module commentary (diff)
downloadguile-ssh-dd3f2a411d3fb6eeabb01068ea869b2fff46f568.tar.gz
shell.scm (fallback-pkill): Use 'fallback-pkill'
* modules/ssh/shell.scm (fallback-pkill): Use 'fallback-pkill'. (fallback-pgrep): Return PIDs as the 1st value.
Diffstat (limited to 'modules/ssh/shell.scm')
-rw-r--r--modules/ssh/shell.scm23
1 files changed, 12 insertions, 11 deletions
diff --git a/modules/ssh/shell.scm b/modules/ssh/shell.scm
index 1f28e30..dd683b0 100644
--- a/modules/ssh/shell.scm
+++ b/modules/ssh/shell.scm
@@ -106,17 +106,6 @@ Return two values: a check result and a return code."
signal
pattern)))
-(define* (fallback-pkill session pattern #:key (full? #f)
- (signal 'SIGTERM))
- (let-values (((pids exit-status) (pgrep session pattern #:full? full?)))
- (format-log 'functions "[scm] fallback-pkill"
- "pids: ~a (pgrep exit status: ~a)"
- (car pids) exit-status)
- (let ((cmd (format "guile -c '(kill ~a ~a)'" (car pids) signal)))
- (format-log 'functions "[scm] fallback-pkill"
- "going to use this kill command: ~a" cmd)
- (rexec session cmd))))
-
(define (fallback-pgrep session pattern)
"Guile-SSH implementation of 'pgrep' that uses pure bash and '/proc'
filesystem. Check if a process with a PATTERN cmdline is available on a NODE.
@@ -130,6 +119,7 @@ for p in $(ls /proc); do
if [[ \"$name\" =~~ Name:.*guile ]]; then
cmdline=$(cat \"/proc/$p/cmdline\");
if [[ \"$cmdline\" =~~ ~a ]]; then
+ echo $p
exit 0;
fi;
fi;
@@ -144,6 +134,17 @@ exit 1;
".*")))
(rexec session (make-command ptrn))))
+(define* (fallback-pkill session pattern #:key (full? #f)
+ (signal 'SIGTERM))
+ (let-values (((pids exit-status) (fallback-pgrep session pattern)))
+ (format-log 'functions "[scm] fallback-pkill"
+ "pids: ~a (pgrep exit status: ~a)"
+ (car pids) exit-status)
+ (let ((cmd (format "guile -c '(kill ~a ~a)'" (car pids) signal)))
+ (format-log 'functions "[scm] fallback-pkill"
+ "going to use this kill command: ~a" cmd)
+ (rexec session cmd))))
+
(define (command-available? session command)
"check if COMMAND is available on a remote side."
(receive (result rc)