title: Why the child process terminated ?? please explain me?
body: <p>I  work with the tcsetpgrp() function, i run this code in gcc complier. I want to change the STDOUT_FILENO to a new group, which was created by the child process.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  int
  main (void)
  {
    printf("Parent pgid=%d\n", getpgrp());
    printf("STDOUT(parent)=%d\n", tcgetpgrp(STDOUT_FILENO));
    pid_t pid;
    if(0 == (pid = fork()))
      {
        setpgid(0, 0);     
        printf("child pgid=%d\n", getpgrp());
        if(0 != tcsetpgrp(STDOUT_FILENO, 0))
          perror("Error");
        printf("After changing %d\n", tcgetpgrp(STDOUT_FILENO));
        exit(0);
      }
    wait(0);
    return 0;
  }
  </code></pre>
  
  <p>in that child process when the tcsetpgrp() function reaches the child process terminated and the exit status doesn't report to parent.</p>