init and process group id's for SYS V

David J. Carpenter djc at chinet.UUCP
Tue Sep 9 03:35:56 AEST 1986


I am developing a kind of "auxiliary init" program for SYS V, that spawns gettys
for lines just being connected to a data switch.  What sequence does
/etc/init use to spawn a getty (or whatever)?  I guessed at it, but
I am having problems getting the process group id, the tty group id, and
the controlling terminal (?) right in the resulting child process.  I fork,
then close fd's 0-2, do a setpgrp(), then three fopens for the terminal line
that it will be attached to, then a signal(SIGHUP, SIG_IGN) to ignore the
parent dieing, then another fork which does the exec(getty).  The 
intermediate parent then exits, and the SIGHUP signal is set back to
SIG_DFL.  I have my own getty which doesn't mess with
stdin stdout and stderr, but does an ioctl, prints a welcome message,
then exec's login.   I have a problem where the reulting -sh has a
process group id of 0.  Then the interrupt key doesn't work (SIGINT).
According to the programmer's manual a setpgrp should solve this, but
if a add a setpgrp to my getty, then login says "Login incorrect" before
asking for the password, because it can't open /dev/tty to read  the
password.  /dev/tty is supposed to related to the process group id.
So, how does /etc/init do it?

Also, how does /etc/init know which child process has died when it gets
a SIGCLD?  According to the prog. manual, wait() gives you the status,
but not the process number.  Perhaps the process number is passed as an
additional argument to the signal catching function?

				Any help is greatly appreciated,
-- 
					...!ihnp4!chinet!qpsn!david
					David Carpenter
					[home] (312) 545-8076
					[work] (312) 787-9343



More information about the Comp.unix.wizards mailing list