summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-12-25 18:29:31 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-12-25 18:29:31 +0300
commit596abc086e00da7adac7351026aea7e100e6703c (patch)
tree3a46c50b9ee6d77c962e43d726faed0bf2682abc /modules
parentshell.scm: Add/update docstrings (diff)
downloadguile-ssh-596abc086e00da7adac7351026aea7e100e6703c.tar.gz
shell.scm (fallback-pgrep): Add dumb 'full?' option
* modules/ssh/shell.scm (fallback-pgrep): Add dumb 'full?' option so the procedure can be used as drop-in replacement to 'pgrep' where full search is performed (e.g. in (ssh dist node)). * modules/ssh/dist/node.scm (node-server-running?): Update.
Diffstat (limited to 'modules')
-rw-r--r--modules/ssh/dist/node.scm10
-rw-r--r--modules/ssh/shell.scm5
2 files changed, 5 insertions, 10 deletions
diff --git a/modules/ssh/dist/node.scm b/modules/ssh/dist/node.scm
index 8bcfdf7..f58d9f1 100644
--- a/modules/ssh/dist/node.scm
+++ b/modules/ssh/dist/node.scm
@@ -273,7 +273,8 @@ listens on an expected port, return #f otherwise."
(and (not (eof-object? line))
(string-match "^GNU Guile .*" line))))))
- (let ((pgrep? (procps-available? node)))
+ (let* ((pgrep? (procps-available? node))
+ (pgrep (if pgrep? pgrep fallback-pgrep)))
(unless pgrep?
(format-log 'rare
"node-server-running?"
@@ -282,25 +283,18 @@ listens on an expected port, return #f otherwise."
" ~a; falling back to the Guile-SSH pgrep implementation")
node))
(receive (result rc)
- (if pgrep?
(pgrep (node-session node)
(format #f "guile --listen=~a"
(node-repl-port node))
#:full? #t)
- (fallback-pgrep (node-session node)
- (format #f "guile --listen=~a"
- (node-repl-port node))))
(or (and (zero? rc)
(guile-up-and-running?))
;; Check the default port.
(and (= (node-repl-port node) %guile-default-repl-port)
(receive (result rc)
- (if pgrep?
(pgrep (node-session node)
"guile --listen"
#:full? #t)
- (fallback-pgrep (node-session node)
- "guile --listen"))
(and (zero? rc)
(guile-up-and-running?))))))))
diff --git a/modules/ssh/shell.scm b/modules/ssh/shell.scm
index 1e67309..0adeb5b 100644
--- a/modules/ssh/shell.scm
+++ b/modules/ssh/shell.scm
@@ -110,10 +110,11 @@ return code."
signal
pattern)))
-(define (fallback-pgrep session pattern)
+(define* (fallback-pgrep session pattern #:key (full? #f))
"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.
-Return two values: a check result and a return code."
+Note that FULL? option is not used at the time (the procedure always perform
+full search.) Return two values: a check result and a return code."
(define (make-command ptrn)
(format #f "\
echo '