From owner-freebsd-questions Mon Jul 17 15:43:13 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mx3.mail.ru (mx3.mail.ru [194.67.23.37]) by hub.freebsd.org (Postfix) with ESMTP id 1306337B5D3 for ; Mon, 17 Jul 2000 15:43:07 -0700 (PDT) (envelope-from debian@mail.ru) Received: from f6.int ([10.0.0.58] helo=f6.mail.ru) by mx3.mail.ru with esmtp (Exim 3.14 #4) id 13EJbM-000CNz-00 for freebsd-questions@freebsd.org; Tue, 18 Jul 2000 02:43:04 +0400 Received: from mail by f6.mail.ru with local (Exim 3.14 #4) id 13EJbL-000I2a-00 for freebsd-questions@FreeBSD.ORG; Tue, 18 Jul 2000 02:43:04 +0400 Received: from [212.188.101.244] by koi.mail.ru with HTTP; Mon, 17 Jul 2000 22:43:03 +0000 (GMT) From: "Вова Камушкин" To: freebsd-questions@FreeBSD.ORG Subject: tty programming Mime-Version: 1.0 X-Mailer: mPOP Web-Mail 2.19 X-Originating-IP: [212.188.101.244] Reply-To: "Вова Камушкин" Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit Message-Id: Date: Tue, 18 Jul 2000 02:43:04 +0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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