Date: 23 Jul 2003 17:33:37 +0000 From: Andrew Barton <andrevv@users.sourceforge.net> To: freebsd-questions@freebsd.org Subject: forkpty and fdopen Message-ID: <1058981617.2733.6.camel@localhost>
next in thread | raw e-mail | index | archive | help
I'm trying to make a program that uses forkpty(), then runs sh in the child process, and then writes to the child using streams. But it doesn't work! It hangs on the wait() call; apparently the child never sees the "exit\n". #include <unistd.h> #include <sys/types.h> #include <stdio.h> main() { int fd; pid_t pid; pid = forkpty (&fd, 0, 0, 0); if (pid == 0) { execlp ("sh", "sh", (void *)0); _exit (1); } else if (pid == -1) { exit (1); } else { FILE *F; F = fdopen (fd, "w"); fprintf (F, "exit\n"); fflush (F); wait (0); } exit (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1058981617.2733.6.camel>