Hi there,

so I think that wait() waits until a child terminates (either through signal or exit). So let's say the father makes a fork() and then just wait(). The child uses exec() to execute another program. Well, and now what's happening? The exec call never comes back (in case it was succesfull). So how long does the father waits now?

Here's the code I'm using:
Code:
#include <stdio.h>
#include <fcntl.h>  
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main() {
   pid_t pid ;
   if ( ( pid = fork () ) < 0 ) {
      perror ("fork");
      return 1;
   }
   if ( pid == 0 ) {
      close (1);
      if ( open("XXX", O_WRONLY | O_CREAT | O_TRUNC, 0666) < 0) {
         perror("open");
         return 2;
      }
      execlp("cat", "cat" ,NULL);
      perror("exec");
      return 3;
   } else {
      wait (0); //for how long does the father waits?
      return 0;
   }
}
In this particular case I think that the father remains until cat is forced to exit, but I'm not sure.

Any suggestions are welcome

Thanks
TurboToJo