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]

Parenthood seems to be lost when the parent is exeeced


Hi,

The parenthood seems to be lost when the parent is execed.
Here is a sample code

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <windows.h>

int main(int argc, char **argv)
{
 int status;

 if (argc > 1)   {
   printf ("Execed Parent: Cygwin: %d Windows: %lu \n",
       getpid (), GetCurrentProcessId ());
   wait(NULL);
   printf("Parent has waited its child\n");
   return 0;
 }
 switch (fork ())   {
 case 0: // Child
   sleep(1);
   printf("Child Cygwin: %d Windows: %lu Parent= %d has ended\n",
      getpid (), GetCurrentProcessId (), getppid());
   break;
 default: // Parent
   printf ("Parent : Cygwin: %d Windows: %lu\n",
       getpid (), GetCurrentProcessId (), getppid());
   execl ("./x", "x", "child", NULL);
   break;
 }
 return 0;
}

Here is the execution of the code

Laurent Najman@PC4354B /cygdrive/d/src/XXX
$ gcc -o x x.c

Laurent Najman@PC4354B /cygdrive/d/src/XXX
$ ./x
Parent : Cygwin: 4308 Windows: 5080
Execed Parent: Cygwin: 4308 Windows: 4728
Parent has waited its child

Laurent Najman@PC4354B /cygdrive/d/src/XXX
$ Child Cygwin: 4784 Windows: 4784 Parent= 1 has ended


Normally, I would expect the parent to be 4308, and I would expect that parent to wait for its child.
Is this cygwin behavior a normal behavior?


Thanks in advance,
Laurent Najman


-- 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


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