I've got the 2.4 kernel, and I'm trying to use the forkpty() system call
with the standard I/O stream functions. The calls to forkpty() and
fdopen() and fprintf() all return successfully, but the data never seems
to get to the child process. In this simplified example, I am trying to
open a shell in a pseudo terminal and then send it the string "exit\n"
and then wait for it to die. But the shell apparently never sees the
"exit\n", and the parent waits forever.
#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) {
return 1;
} else {
FILE *F;
F = fdopen (fd, "w");
fprintf (F, "exit\n");
fflush (F);
wait (0);
}
return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:24 EST