From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: vapnik spaknik Newsgroups: gmane.lisp.guile.user Subject: how to kill child process? Date: Sun, 23 Aug 2020 19:50:58 +0000 (UTC) Message-ID: <2139767403.5164633.1598212258730@mail.yahoo.com> References: <2139767403.5164633.1598212258730.ref@mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20600"; mail-complaints-to="usenet@ciao.gmane.io" To: guile users mailing list Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Aug 23 21:54:55 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9w4t-0005H9-Gd for guile-user@m.gmane-mx.org; Sun, 23 Aug 2020 21:54:55 +0200 Original-Received: from localhost ([::1]:36782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9w4s-0001Sv-Fm for guile-user@m.gmane-mx.org; Sun, 23 Aug 2020 15:54:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9w1F-0003M9-La for guile-user@gnu.org; Sun, 23 Aug 2020 15:51:09 -0400 Original-Received: from sonic307-55.consmr.mail.gq1.yahoo.com ([98.137.64.31]:38605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k9w1B-0006MD-IF for guile-user@gnu.org; Sun, 23 Aug 2020 15:51:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1598212263; bh=FOBMpFszXo+nh5dDGZX0Cp+WAdslgSeDw968X9ZVT4k=; h=Date:From:To:Subject:References:From:Subject; b=ZltPvXNOK6cadGm+hiPrhhKt5cAUQImOvFYPVPYtwEWRoNZ6AC4R30pcKN4yDGJEXZ1fsqdxmBicivS63EgdQ5hR1oNqo5UctZm4/HjSurDQW3uDwbsBIVqO2Y6c9HuQlIC035LIvENRK5tey9HGlIEv6ou143x2XbUg6ejxL/80/5QVhZ4Y958jKx1+gjvlyCue6+qvrrCK+D9PxgDjB7D5ZzIdW5LctQInwbH7z61xEJL5aTOyZoG84CiNwEK+Ry4wuV+EtMsA/kpsVjN/3xH0coBJOb9ummDNKorEhqzpS5DxKFpbG3LoMjclIoEIe2MfL5ispRgvZp0bXsazxg== X-YMail-OSG: Ovb6LNsVM1lIqT57isMB5a2fRlZutTs3ZN1T84CkUU_YTj4Hf9k3yONt35NfhXu xsTM2kV2gmTBwyhlv7p8FMOPocs9o0f9VrM9.GBP77RnT70cIqh.bpu043klu2oUI9SWIMv5aruO BlL5V18VaMu6Wg41Y_a1tyo6dBXnMWGzYE2z4kNJG4siKHwXAUY209kNdwy3WMBZwWwPpmijBqrN ufq70WpVNbYk.l3JKmXO5.BM.RU6IAA1m9XfjzMXJO.TQJilc1SxZTwONhhQ7oPzZLTbqpqfZRxB Dpfap4AHzWOX7vOWZwZnKwdmAVxuq.hTrk94XbtamHc.vrh2irPuN7VaB0ZfQ.f1WFpxXZasawwP kIMamkqskiaI2oOqRBthGkhIDrkX5KpQSVj246ZOZ8.hE5UwFwp2mJnY50aT.UCOcq.QQ_YwCHQH XA.ptGhohTKR19xMmG9EIQa1dr17gHaA44SA7VFTL09VW00S.4JSU2xCqQcglhIbC3y6IybRNPoD uQqs69fDJMiQ3ftlt2oTR3uEnbynWDEvLU0kyzolmh01Xf2OdblcYuvOY3vcOvcQ.a3O5DiK4k6f cf1yPROi1s6WQc5JNs.Cwpp6bYXakCW3BINGT.vdIyH0OH4XHErnM5cRjqLsk42qHCNcuPIzklnF jc9Rco4uTI5ofocW52J3F9XueW_Bs5fv3gM5g86jufbeywH1QX1y8y9HiMXU8IYQC8N.dDuXNp.F iBFOlQ1XgfJG9ujbItOoMM7mVWc_xQVHdBLPZ2ILyuVyLLVUSzWmV9CXVvvLDBaiwXt8g84zm4yg w__kExXqWrDnUWw6xIhC.qjt5lmVErUFM2zsu1b2hh Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.gq1.yahoo.com with HTTP; Sun, 23 Aug 2020 19:51:03 +0000 X-Mailer: WebService/1.1.16455 YMailNodin Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36 Received-SPF: pass client-ip=98.137.64.31; envelope-from=vapniks@yahoo.com; helo=sonic307-55.consmr.mail.gq1.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/23 15:51:03 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16826 Archived-At: 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 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.