need help with bash and opentpy
I am trying to open a pseudo-terminal and redirect STDIN, STDOUT, and
STDERR to the slave file descriptor created by openpty for ultimately
running the default shell. My code works great when I exec "ls" or some
other process, but does not work with any of the shells. Now I know this
is possible because xterm does this. Actually bash works okay until I
dup2(slave_fd,STDIN_FILENO) in the child process. A rough flow of my code
is below. I seem to be at an impasse on this and any help would be
appreciated.
1. get current term attributes with tcgetattr()
2. openpty() supplying the term attributes from step 1
3. fork()
4. in child process: copy slave_fd, to STDIN/OUT/ERR descriptors using
dup2()
5. in child process: execv("/bin/sh",NULL);
Thanks in advance,
Bryan
.
Relevant Pages
- Re: Getting current time in milliseconds
... See "perldoc -q env" for a possible workaround. ... But then it is acting as a new parent process, not as a child process. ... because it sets the value in the currently running Perl process, ... If you want to modify the value of the shell ... (comp.lang.perl.misc) - Re: Changing director inside a program
... tiny little shell ... A child process cannot change a parent process' cwd; ... can only change it's own cwd, which can be inherited by /it's/ children. ... command was a shell builtin ... (comp.os.linux.misc) - Inappropriate ioctl for device when calling tcsetpgrp() on Solaris
... I'm writing a shell program that will do background/foreground executions. ... On Solaris, when I put a child process to background, I use tcsetpgrp(fd, ... shell_pgrp_id) to let my shell have the control of terminal. ... (comp.unix.programmer) - Re: Getting current time in milliseconds
... See "perldoc -q env" for a possible workaround. ... But then it is acting as a new parent process, not as a child process. ... but all of that is some magic on the shell side and applies to any ... doesn't have anything to do with Perl and that's why the answer in the ... (comp.lang.perl.misc) - Re: Propblem with TerminateProcess
... control, then you need to use a direct SPAWN rather than a SHELL. ... The child process will be in both cases what you pass as szProgram and will be a direct child process of the calling process. ... (microsoft.public.win32.programmer.kernel) |
|