FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY
From: Usha (u_sesh_at_yahoo.com)
Date: 25 Apr 2003 12:00:13 -0700
I am stumped! My C++ program fork()s and the child exec()s a "ksh".
The input to the child (KSH) comes from the parent thro' a pipe(). ie,
the STDIN of the child is dup()ed to be the read end of the pipe. The
parent gets its STDIN and redirects it to the child. The ksh is made
interactive just so that the prompt is displayed.
But the exec()ed shell does not behave like a normal shell. Some of
the problems I am experiencing when running commands from the exec()ed
1) I cannot use stty since the input device is not a tty.
2) When I telnet to another host, the userid is echoed in the next
line, after entering the userid at the "Login" prompt, and entering
<CR>. Also, the password gets echoed on the screen as I type. I tried
to use the "mode" feature of telnet to suppress echoing, but when I
use the esc character to get to the telnet prompt, it does not
understand the escape character, and thinks it is the login userid. I
am guessing it has to do with the input device not being a tty.
Does anybody know how to get around this problem? Is there a way to
fool the shell to think the input device is a tty and not a pipe, so
that it starts behaving normally ? Any help is truely appreciated.
Thanks in advance!