new copyright notice
[unix-history] / usr / src / sbin / nfsiod / nfsiod.c
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* %sccs.include.redist.c%
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1989 Regents of the University of California.\n\
All rights reserved.\n";
#endif not lint
#ifndef lint
static char sccsid[] = "@(#)nfsiod.c 5.3 (Berkeley) %G%";
#endif not lint
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* Global defs */
#ifdef DEBUG
int debug = 1;
#else
int debug = 0;
#endif
/*
* Nfsiod does asynchronous buffered I/O on behalf of the NFS client.
* It does not have to be running for correct operation, but will improve
* throughput. The one optional argument is the number of children to fork.
*/
main(argc, argv)
int argc;
char *argv[];
{
register int i;
int cnt;
if (debug == 0) {
if (fork())
exit(0);
{ int s;
for (s = 0; s < 10; s++)
(void) close(s);
}
(void) open("/", O_RDONLY);
(void) dup2(0, 1);
(void) dup2(0, 2);
{ int tt = open("/dev/tty", O_RDWR);
if (tt > 0) {
ioctl(tt, TIOCNOTTY, (char *)0);
close(tt);
}
}
(void) setpgrp(0, 0);
signal(SIGTSTP, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGHUP, SIG_IGN);
}
if (argc != 2 || (cnt = atoi(argv[1])) <= 0 || cnt > 20)
cnt = 1;
for (i = 1; i < cnt; i++)
if (fork() == 0)
break;
async_daemon(); /* Never returns */
exit(1);
}