From 596abc086e00da7adac7351026aea7e100e6703c Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Sun, 25 Dec 2016 18:29:31 +0300 Subject: 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. --- modules/ssh/dist/node.scm | 10 ++-------- modules/ssh/shell.scm | 5 +++-- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'modules') 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 ' -- cgit v1.2.3