where goes the prompt ?

where goes the prompt ?

Post by Dongxiao Y » Sun, 17 Jul 1994 05:11:01



Hello, world,

  I wrote a few lines programm doing the following,
  the main program create two pipes, then fork-exec
  another which is just "sh", then the parent read from stdin and write to
  the pipe(the child has dup2 the other end of pipe to 0,
  and 1, 2 to an end of the another pipe), and read from the
  other pipe and write to stdout.
  (Actualy the parent will write the output of "sh" to a socket)

  Sounds like a simple program, and it works, for instance
  I can set the DISPLAY, and type xterm the forked "sh" will run the xterm,
  or I can do other interactive things.

  The problem is it seems "sh" does not write the PROMPT to stdout or stderr,
  since I duped both 1,2, but I do not get the prompt.

  Any ideas where the PROMPT goes?  

Dongxiao

 
 
 

where goes the prompt ?

Post by Barry Margol » Mon, 18 Jul 1994 16:12:50



>  the main program create two pipes, then fork-exec
>  another which is just "sh", then the parent read from stdin and write to
>  the pipe
...
>  The problem is it seems "sh" does not write the PROMPT to stdout or stderr,
>  since I duped both 1,2, but I do not get the prompt.

The shell only prompts when it's in interactive mode.  It is interactive if
input and output are connected to a terminal, or the -i option is given.
In your case input and output are connected to pipes, so you'll need to use
the -i option to force interactive mode.
--
Barry Margolin
System Manager, Thinking Machines Corp.



 
 
 

where goes the prompt ?

Post by Dongxiao Y » Tue, 19 Jul 1994 12:48:22




>>  the main program create two pipes, then fork-exec
>>  another which is just "sh", then the parent read from stdin and write to
>>  the pipe
>...
>>  The problem is it seems "sh" does not write the PROMPT to stdout or stderr,
>>  since I duped both 1,2, but I do not get the prompt.
>The shell only prompts when it's in interactive mode.  It is interactive if
>input and output are connected to a terminal, or the -i option is given.
>In your case input and output are connected to pipes, so you'll need to use
>the -i option to force interactive mode.
>--
>Barry Margolin
>System Manager, Thinking Machines Corp.

 Actually I used interactive mode without success, I now use a pair
 of pty-tty instead of the pipes, and everything works. Now I run the server
 as a daemon somewhere, and  login with the client (without typing  a password).