X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <2ce9650b0811140323h2e620979w77118815bed87fdd@mail.gmail.com> Date: Fri, 14 Nov 2008 11:23:28 +0000 From: "Chris January" To: cygwin AT cygwin DOT com Subject: Re: Kill cygwin process form task manager In-Reply-To: <448067AB8643614285E9B1DC376F273C0241F883@bermail.de.aastra.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <448067AB8643614285E9B1DC376F273C0241F883 AT bermail DOT de DOT aastra DOT com> X-Google-Sender-Auth: f178cffc2d92893f X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Nov 14, 2008 10:20am, Michael Wiedmann wrote: > I need hints how to act if someone kills my Cygwin (parent) process using Windows task manager and I want to kill all forked child processes. > > I already keep a list of all childs pids and can kill them successfully in an SIGINT handler (if the programm is started in foreground and is interrupted e.g. by Ctrl-C). Untested on Cygwin, but works on Linux, etc.: 1. Create an anonymous pipe using the pipe function. 2. Fork the child. 3. Close the read fd in the parent and the write fd in the child. 4. Have child select on the read fd. 5. When the parent dies the select will return. 6. Try to read from the pipe. If read returns 0, i.e. end-of-file the parent is dead. Alternatively, do it the other way round, with the child occasionally writing to the pipe and the parent draining it. The child will get SIGPIPE when the parent dies. Chris -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/