usenet@mcdchg.UUCP (03/13/87)
I recently wrote a new getty for a RT built around curses. My question is about why one version works and another not. The following code out lines the differences in the two versions. Version 1 does not work while Version 2 does. Version 1. main(tty) char *tty; /* tty to use */ { set_ioctl(); /* put in known mode */ close(0); close(1); close(2); dup(dup(open(tty,2))); write_utmp(tty); /* do utmp stuff */ get_logid(logid); /* prompt for logid */ execle("/bin/login",logid,NULL); } Version 2. main(tty) char *tty; /* tty to use */ { set_ioctl(); /* put in known mode */ close(0); close(1); open(tty,2); close(2); dup(0); dup(1); write_utmp(tty); /* do utmp stuff */ get_logid(logid); /* prompt for logid */ execle("/bin/login",logid,NULL); } Does close() cause something to settle that dup() needes from the open()? The problem with Version one is that /dev/tty does not get attached to the control group. Any idea's that might explain this mystery would be greatly appreciated!! -- Larry Baird Dept. of Computer Science uucp: {ihnp4!decvax,peora}!ucf-cs!baird University of Central Florida Orlando, FL 32816
usenet@mcdchg.UUCP (03/27/87)
in /usr/src/sys/sys/tty.c fuction "ttyopen"
there is the following code:
pp = u.u_procp; -- proc table entry
if (pp->p_pgrp == 0) { -- no proc-group ??
u.u_ttyp = tp; -- set /dev/tty pointer
if (tp->t_pgrp == 0) -- no tty-proc-group ??
tp->t_pgrp = pp->p_pid; -- effectivly create new group-leader
pp->p_pgrp = tp->t_pgrp; -- alwasy set proc-group
}
in ttyclose(), which is only called for the *FINAL* close, we have:
tp->t_pgrp = 0;
tp is always a pointer to the tty struct.
t_prgp is the process group used for keyboard signals, and
p_pgrp is the process group shown by ps l
(t_* are fields in the tty struct; p_* are fields in the proc struct.)
As far as I know, u_ttyp can only be cleared by
doing an ioctl (TIOCNOTTY) on /dev/tty
(see the ioctl routine in .../tty_tty.c)
Your process group can be controlled by ioctls too (see tty(4) for
details on those.)
Check your login program carefully, and make *SURE* that t_pgrp is
set *BEFORE* login becomes csh!!! (If not, and you're useing
version #2, then I think that the users csh will be in the p-group
of init (or whoever you have starting getty!!!!! It would not be
nice for a user to send a keyboard-quit-signal to init, would it??
Whenever in doubt, read the source!!!!! (We'll make a hacker out
of you yet!!)
Hope this is of some help
--
John W
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name: John F. Wardale
UUCP: ... {seismo | harvard | ihnp4} !uwvax!astroatc!johnw
arpa: astroatc!johnw@rsch.wisc.edu
snail: 5800 Cottage Gr. Rd. ;;; Madison WI 53716
audio: 608-221-9001 eXt 110
To err is human, to really foul up world news requires the net!