Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Date: Thu, 15 Sep 2005 19:30:16 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: problem with getppid() Message-ID: <20050915173016.GD5395@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <20050915153358 DOT GW5555 AT calimero DOT vinschen DOT de> <20050915165446 DOT GC5395 AT calimero DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2i On Sep 15 10:08, Eduardo Chappa wrote: > *** Corinna Vinschen (pcorinna-cygwin AT cygwin DOT cometh) wrote in the cygwin...: > > :) On Sep 15 09:18, Eduardo Chappa wrote: > :) > The problem I have is that when Pine gets ppid == 1 it exits [...] > :) > :) That's a bug in pine. It means, you can't run pine from cmd.exe, resp. > :) command.com. > > Corinna, > > I can run Pine in cmd.exe, I have no problem with that. Let me give you > and idea of the code. > > res = select() > > if(res == 0){ > if(getppid() == 1) > "exit(0)"; > > continue doing its stuff; > } > > This code runs perfectly in Linux, both in terminal and under gdb, and it > runs very well in Cygwin, but as you point out it does not run under > cmd.exe. It is not a problem that it does not run in the latter case > because one can run it under cygwin on a bash shell, so the latter is not > an issue that is specially troubling. The real issue is that I get an > "exit(0)" under gdb. That's my real issue. That's what I'd like to solve. Let me reitterate. If your parent process is a native Windows process, there's no parent PID available. This is nothing new and Cygwin emits the PPID 1 already since the last century. While on Linux (or whatever) this means that the parent is the init process, on Cygwin it means, you don't have a Cygwin parent process. Having no Cygwin parent process means, you don't have a chance to communicate with the parent process by means of POSIX system calls. The bottom line of this is, if you want to port pine to Cygwin correctly, you will have to change the above code to something along the lines of if(res == 0){ #ifndef __CYGWIN__ if(getppid() == 1) "exit(0)"; #endif continue doing its stuff; } This minimal porting effort will have only positive results, pine suddenly works fine from cmd/command and also you won't have problems to debug it using GDB. So it helps everybody. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat, Inc. -- 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/