Re: Question about pipes and terminals

From: Josef Möllers (josef.moellers_at_fujitsu-siemens.com)
Date: 02/02/04


Date: Mon, 02 Feb 2004 17:09:34 +0100


"Andrey Sh." wrote:
>
> I am developing a module that runs and tracks another executable. One
> of the requirements was the ability of user to work interactively with
> the executable. For example if my module is passed a shell as
> executable, the user should be able to use the shell normally.
>
> When i used simply fork() and exec() waiting for SIGCHLD to idicate
> that the child has finished directly it all worked well. Then i added
> 3 pipes to redirect stdin/stdout/stderr to the executable. Now i wait
> for the executable and all its children to finish by waiting for
> stdout and stderr to close. The user input is redirected to the child
> process through a pipe. Now when i execute a shell, i am still able to
> run commands in the shell but i dont see the prompt and other terminal
> functions (like escape+P etc). Is this something related to pipes?

Yes: a pipe is not a tty!
You can use a pseudo-tty to communicate with your child. It looks like a
tty, but behaves like a pipe.

> It
> looks like if the terminal is still with the father process (the
> module). Anyone has any ideas how to make the terminal go to the
> child?

You either leave stin/out/err open when fork-ing the child or you open
another device/pipe. Can't have both.

Josef

-- 
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


Relevant Pages

  • perl/php connect-back backdoor?
    ... you can use the reverse shell from THC ( ... Well, a program is run on the internal host, which spawns a child every day ... internet via a legitimate looking http request and sends it ready signal. ... You can use netcat compiled with the execute option and run with a time ...
    (Vuln-Dev)
  • Re: Question about pipes and terminals
    ... the user should be able to use the shell normally. ... > that the child has finished directly it all worked well. ... > process through a pipe. ... Now when i execute a shell, ...
    (comp.os.linux.development.system)
  • Re: which process will be executed first whether the child or parent?
    ... # SR> after that all the statements will be executed twice both by child and parent ... # SR> i want to know whether child will execute first or parent? ... # If you want some strict order of execution, ...
    (comp.unix.programmer)
  • Re: Duplicate output line in child-parent process.
    ... Here's the output that I've received and you'll note duplicate "Value ... The first line is printed by the child, ... second one is printed by the parent. ... They will both execute all the ...
    (comp.unix.programmer)
  • Re: Duplicate output line in child-parent process.
    ... Here's the output that I've received and you'll note duplicate "Value ... The first line is printed by the child, ... second one is printed by the parent. ... They will both execute all the ...
    (comp.unix.programmer)