Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jul 2000 02:43:04 +0400
From:      "Вова Камушкин" <debian@mail.ru>
To:        freebsd-questions@FreeBSD.ORG
Subject:   tty programming
Message-ID:  <E13EJbL-000I2a-00@f6.mail.ru>

next in thread | raw e-mail | index | archive | help
Hi im Ref from Russia.
Im realy need your help. Sory for bad english -)
Ok.

Im wrote program (on freebsd 4.0) which open next free "in system" pty,
associated wich them std streams and executed /bin/sh
but I have one problem. The progam executed im background mode:

bash#tty
ttyp3
bash#./prgoa
bash#
look in ps
bash#ps aux
............
root    1295  0.0  0.6   620  364  p4  Ss+   1:51     0:00.00  (sh)
............
bash#

As you can see the /bin/sh was executed in p4 "nex free pty".

And now my qestion :

I can't execute the program in foreground mode. In real time im can execute
commands in sh opended by this program only trogh next cmd line :
bash#watch -W tty;

Whow I cam run this program in foreground mode ?

I have use next algorithm:

main()
  |	int linedesciplene;
  |	int master_side;
  |	int slave_side;
  |	char tty_name[64]="NULL";
  |	struct terios tio;
  |	struct winsize w;
  |	etc
  |
  |
  |
  tcgetattr(stdin,&tio) /*get termios strus from already opended tty and
  |			associated with std streams */
  |
  set up struct winsize
  w.ws_row = 25;
  w.ws_col = 132;
  w.ws_xpixel = w.ws_ypixel =0;
  |
  openpty(&master_side,&slave_side,tty_name,&tio,&w); 
  /*openpty will be open next free pty with tio and w
  and return master descriptor slave descriptor man path 
  in tty_name char variable*/ 
  |
   fork(){
	| /* In chaild */
	|
        pgid=setsid();
	|
	|
        login_tty(slave_tty);
	/* will be made the slave desc controlling tty */
	/* and will be accociated slave desc with std streams */
	|
        tcsetpgrp(stdin,pgid);
	|
        Setup line discepline TTYDIC;
        by iosctl()
	|
	|
        exec(/bin/sh)
	|
	}
}
/*end*/

So imho login_tty() func must associate just opended tty with std 
stream like im read in man and then exec(/bin/sh) must work in foreground
like this:

bash#tty
ttyp3
bash#./proga
#tty
ttyp4
#

but I can't made this result;

So.
Please help me Im realy need your help becouse this is module of big program and that stoped all project. If you can't help, please say whea I can
read abou this.

debian@mail.ru
Again sory for bad english.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E13EJbL-000I2a-00>