delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:from:to:mime-version | |
:content-transfer-encoding:content-type:subject:date; q=dns; s= | |
default; b=Jr7q2TZC+q3lFNuClIdTk+wfb9XrE/oP/TGA0keXPgcOfRoZN4bhQ | |
dpYI7Hr0jiLWJXqPNG7MWOkqZr3iFnrmB/XCAQbKAQCOAyXsEP9IDqKoLYCg7lDJ | |
lRL4zKNeTn018kFhtNwVY2NEiP88XMwX2QkGIKdYORI9uYvBueUidI= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:from:to:mime-version | |
:content-transfer-encoding:content-type:subject:date; s=default; | |
bh=/dFoB/HqaYvDwi9FEhQ9slzZ1Ys=; b=d2LCcLNU0flTwERMb6hfrAKO6rPG | |
IeeenU06rb3zlBPnwCfknrS3vF7py9XXdRbKOTqnVoZkDYyBPpFurlVYVzrxG9O9 | |
2UJr5z2Kv62faNZoj1RK3G8NvvpoGRQXvjsB3Md5kVj+Bp65ASg7txnFJY0aje6o | |
Cc0cjaGH3XOWwMA= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:webmail, 10312, relationship |
X-HELO: | out3-smtp.messagingengine.com |
X-ME-Sender: | <xms:e79IWSKUBM77HM-2UeUYx9FczpRRL4oGmmiuHHyOkLqG9rq-MkPBpA> |
Message-Id: | <1497939835.2871765.1014990544.3396EEF9@webmail.messagingengine.com> |
From: | Ronald Otto Valentin Fischer <ashi DOT niwatori AT the-quickest DOT com> |
To: | cygwin AT cygwin DOT com |
MIME-Version: | 1.0 |
Subject: | Killing-Process woes |
Date: | Tue, 20 Jun 2017 08:23:55 +0200 |
I'm spawning processes in background, but have problems killing them. Here is the setup: My script (zsh) creates one or more processes in the background, and waits until they are finished. I have also set up a trap for SIGINT, with the intention that if I press Control-C, the background processes should be killed. I have verified the setup so far, that upon Control-C, the trap function is indeed invoked, and I have all the PIDs of the background processes. The problem is with the actual killing, and here is why: The background processes are actually (zsh-) scripts, which do some setup (basically setting various environment variables), and then invoke a (Cygwin-)Ruby program which does the "real work". The program is executed by something like ruby myprog.rb (Note that this Ruby program is NOT invoked in background). When my SIGINT trap is entered, I can see from ps indeed the relationship between the processes involved, for instance 10852 9296 6224 10536 cons3 3672028 08:05:10 /usr/bin/ruby 9296 6224 6224 11236 cons3 3672028 08:05:10 /usr/bin/zsh The PID of my background process - the zsh wrapper - in this concrete case is 9296, and we can see that this is the parent of the Ruby process, 10852. The problem is that if I just kill 9296, the Ruby process keeps running, orphaned: 10852 1 6224 10536 cons3 3672028 08:05:10 /usr/bin/ruby I've found on Stackoverflow the suggestion to treat this as a process group and use negative PIDs. I tried this too, but it didn't work. Here is a similar example: 5548 10276 5812 2376 cons3 3672028 08:20:43 /usr/bin/ruby 10276 5812 5812 10312 cons3 3672028 08:20:43 /usr/bin/zsh If I do a kill -- -10276 I get the error message kill: -10276: No such process This happens both with the zsh-builtin kill and with /usr/bin/kill Is there a simple way to kill the zsh process in addition to the ruby process, or do I have to analyze the output of the ps command to manually find the PID of the Ruby process and kill it? Ronald -- Ronald Fischer <ronald DOT fischer AT fusshuhn DOT de> http://www.fusshuhn.de/ -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |