FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY

From: Usha (u_sesh_at_yahoo.com)
Date: 04/25/03


Date: 25 Apr 2003 12:00:13 -0700

HI,

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
ksh are:
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!
Usha



Relevant Pages

  • Re: How does one effect O_NONBLOCK?!
    ... once I've created 3 pipes (for stdout, stderr and stdin) ... child and parent processes and then dup2the 3 descriptors into the ... corresponding ends of the pipes in the child before execve-ing. ... end side of the pipe that's connected to stdin of the child process. ...
    (comp.unix.programmer)
  • Re: FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY
    ... >> The input to the child (KSH) comes from the parent thro' a pipe(). ... >> am guessing it has to do with the input device not being a tty. ...
    (comp.unix.solaris)
  • Re: FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY
    ... >> The input to the child (KSH) comes from the parent thro' a pipe(). ... >> am guessing it has to do with the input device not being a tty. ...
    (comp.unix.programmer)
  • Re: FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY
    ... > The input to the child (KSH) comes from the parent thro' a pipe(). ... > the STDIN of the child is duped to be the read end of the pipe. ...
    (comp.unix.solaris)
  • Re: FOOL EXEC()ed SHELL TO THINK STDIN IS A TTY
    ... > The input to the child (KSH) comes from the parent thro' a pipe(). ... > the STDIN of the child is duped to be the read end of the pipe. ...
    (comp.unix.programmer)