+ i = close (pipefd[0]);
+ assert (i == 0);
+ i = close (pipefd[1]);
+ assert (i == 0);
+
+ /* Do not replace STDIN as inferiors query its termios. */
+#if 0
+ i = close (STDIN_FILENO);
+ assert (i == 0);
+ i = open ("/dev/null", O_RDONLY);
+ assert (i == STDIN_FILENO);
+#endif
+
+ /* Do not setpgrp(2) in the parent process as the process-group
+ is shared for the whole sh(1) pipeline we could be a part
+ of. The process-group is set according to PID of the first
+ command in the pipeline.
+ We would rip even vi(1) in the case of:
+ ./orphanripper sh -c 'sleep 1&' | vi -
+ */
+ /* Do not setpgrp(2) as our pty would not be ours and we would
+ get `SIGSTOP' later, particularly after spawning gdb(1).
+ setsid(3) was already executed by forkpty(3) and it would fail if
+ executed again. */
+ if (getpid() != getpgrp ())
+ {
+ perror ("getpgrp(2)");
+ exit (EXIT_FAILURE);
+ }