xref: /original-bsd/sbin/nfsiod/nfsiod.c (revision fa348642)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rick Macklem at The University of Guelph.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 char copyright[] =
13 "@(#) Copyright (c) 1989 Regents of the University of California.\n\
14  All rights reserved.\n";
15 #endif not lint
16 
17 #ifndef lint
18 static char sccsid[] = "@(#)nfsiod.c	5.4 (Berkeley) 06/29/90";
19 #endif not lint
20 
21 #include <stdio.h>
22 #include <signal.h>
23 #include <fcntl.h>
24 #include <sys/types.h>
25 #include <sys/ioctl.h>
26 
27 /* Global defs */
28 #ifdef DEBUG
29 int debug = 1;
30 #else
31 int debug = 0;
32 #endif
33 
34 /*
35  * Nfsiod does asynchronous buffered I/O on behalf of the NFS client.
36  * It does not have to be running for correct operation, but will improve
37  * throughput. The one optional argument is the number of children to fork.
38  */
39 main(argc, argv)
40 	int argc;
41 	char *argv[];
42 {
43 	register int i;
44 	int cnt;
45 
46 	if (debug == 0) {
47 		daemon(0, 0);
48 		signal(SIGINT, SIG_IGN);
49 		signal(SIGQUIT, SIG_IGN);
50 		signal(SIGTERM, SIG_IGN);
51 		signal(SIGHUP, SIG_IGN);
52 	}
53 	if (argc != 2 || (cnt = atoi(argv[1])) <= 0 || cnt > 20)
54 		cnt = 1;
55 	for (i = 1; i < cnt; i++)
56 		if (fork() == 0)
57 			break;
58 	async_daemon();		/* Never returns */
59 	exit(1);
60 }
61