deamon 'shell' wanted

Kartik Subbarao subbarao at phoenix.Princeton.EDU
Sat May 18 07:10:59 AEST 1991


In article <417 at fjcp60.GOV> brinkema at fjc.GOV (John R. Brinkema) writes:
>I am writing a network daemon; it will be started up at 'rc' time.  After
>startup, I want it to lose  all tty-group connections.  I also want it to
>shutdown cleanly (say when shutdown is run).
>
>Does anyone have an example or 'shell' for a deamon.  tnx.  jb.

All you need to do to make sure that the daemon loses its tty associations
is this:

t = open("/dev/tty", O_RDONLY);
ioctl(t, TIOCNOTTY, NULL);
close(t); close(0); close(1); close(2);

This seems to work for my daemons. As for shutting down, if process exits
cleanly (i.e either voluntarily or via kill -9), then the operating system
will take care of closing all fds.



			-Kartik



		

--
internet% ypwhich

subbarao at phoenix.Princeton.EDU -| Internet
kartik at silvertone.Princeton.EDU (NeXT mail)  
SUBBARAO at PUCC.BITNET			          - Bitnet



More information about the Comp.unix.wizards mailing list