This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with getppid()


On Sep 15 10:08, Eduardo Chappa wrote:
> *** Corinna Vinschen (pcorinna-cygwin@cygwin.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]