From: vapnik spaknik <vapniks@yahoo.com>
To: guile users mailing list <guile-user@gnu.org>
Subject: how to kill child process?
Date: Sun, 23 Aug 2020 19:50:58 +0000 (UTC) [thread overview]
Message-ID: <2139767403.5164633.1598212258730@mail.yahoo.com> (raw)
In-Reply-To: 2139767403.5164633.1598212258730.ref@mail.yahoo.com
Hi,
I'm writing a backup script in guile, and want to run rsync several times over the same ssh connection.
From the shell command line I can start an ssh session with a control master socket, and then tell ssh to reuse that socket with each invocation of rsync:
> ssh -S ~/.ssh/%C -N -f remotehost &
> rsync -au -e "ssh -S ~/.ssh/%C remotehost" remotehost:file1 backupdir/file1
> rsync -au -e "ssh -S ~/.ssh/%C remotehost" remotehost:file2 backupdir/file2
and finally, find the pid and kill the ssh session:
> ps -e|grep ssh
> kill <PID>
To do the same thing in guile I tried the following:
(let ((pid (primitive-fork)))
(if (eq? 0 pid)
(execlp "ssh" "ssh" "-S" "~/.ssh/%C" "-N" "-f" "remotehost")
(begin (system "rsync -au -e \"ssh -S ~/.ssh/%C remotehost\" remotehost:file1 backupdir/file1")
(system "rsync -au -e \"ssh -S ~/.ssh/%C remotehost\" remotehost:file1 backupdir/file1")
(kill pid SIGTERM)))
However, this doesn't work because the pid returned by primitive-fork is the pid of the guile thread, not its child ssh process, and killing the guile thread doesn't kill its child process.
I don't want to run (system "kill ssh") because I might have other ssh processes running that I need to keep alive.
It might be possible for me to achieve the same end results using a tunnel with guile-ssh for this particular problem, but I would like to know how to solve the more general problem of killing a long-running child process in guile, since I will probably face this problem again at some point in the future.
Can anyone help me?
Joe Bloggs.
next parent reply other threads:[~2020-08-23 19:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2139767403.5164633.1598212258730.ref@mail.yahoo.com>
2020-08-23 19:50 ` vapnik spaknik [this message]
2020-08-23 20:31 ` how to kill child process? Sebastian Miele
2020-08-23 23:08 ` Sebastian Miele
2020-08-24 11:07 ` vapnik spaknik via General Guile related discussions
2020-08-24 12:05 ` Sebastian Miele
2020-08-24 13:15 ` vapnik spaknik via General Guile related discussions
2020-08-24 14:27 ` Sebastian Miele
2020-08-24 14:33 ` Sebastian Miele
2020-08-24 16:51 ` vapnik spaknik via General Guile related discussions
2020-08-24 18:47 ` Sebastian Miele
2020-08-25 18:21 ` vapnik spaknik via General Guile related discussions
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2139767403.5164633.1598212258730@mail.yahoo.com \
--to=vapniks@yahoo.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).