138870Smckusick /* 238870Smckusick * Copyright (c) 1989 The Regents of the University of California. 338870Smckusick * All rights reserved. 438870Smckusick * 538870Smckusick * This code is derived from software contributed to Berkeley by 638870Smckusick * Rick Macklem at The University of Guelph. 738870Smckusick * 8*42705Sbostic * %sccs.include.redist.c% 938870Smckusick */ 1038870Smckusick 1138870Smckusick #ifndef lint 1238870Smckusick char copyright[] = 1338870Smckusick "@(#) Copyright (c) 1989 Regents of the University of California.\n\ 1438870Smckusick All rights reserved.\n"; 1538870Smckusick #endif not lint 1638870Smckusick 1738870Smckusick #ifndef lint 18*42705Sbostic static char sccsid[] = "@(#)nfsiod.c 5.3 (Berkeley) 06/01/90"; 1938870Smckusick #endif not lint 2038870Smckusick 2138870Smckusick #include <stdio.h> 2238870Smckusick #include <signal.h> 2338870Smckusick #include <fcntl.h> 2438870Smckusick #include <sys/types.h> 2538870Smckusick #include <sys/ioctl.h> 2638870Smckusick 2738870Smckusick /* Global defs */ 2838870Smckusick #ifdef DEBUG 2938870Smckusick int debug = 1; 3038870Smckusick #else 3138870Smckusick int debug = 0; 3238870Smckusick #endif 3338870Smckusick 3438870Smckusick /* 3539865Smckusick * Nfsiod does asynchronous buffered I/O on behalf of the NFS client. 3639865Smckusick * It does not have to be running for correct operation, but will improve 3739865Smckusick * throughput. The one optional argument is the number of children to fork. 3838870Smckusick */ 3938870Smckusick main(argc, argv) 4038870Smckusick int argc; 4138870Smckusick char *argv[]; 4238870Smckusick { 4338870Smckusick register int i; 4438870Smckusick int cnt; 4538870Smckusick 4638870Smckusick if (debug == 0) { 4738870Smckusick if (fork()) 4838870Smckusick exit(0); 4938870Smckusick { int s; 5038870Smckusick for (s = 0; s < 10; s++) 5138870Smckusick (void) close(s); 5238870Smckusick } 5338870Smckusick (void) open("/", O_RDONLY); 5438870Smckusick (void) dup2(0, 1); 5538870Smckusick (void) dup2(0, 2); 5638870Smckusick { int tt = open("/dev/tty", O_RDWR); 5738870Smckusick if (tt > 0) { 5838870Smckusick ioctl(tt, TIOCNOTTY, (char *)0); 5938870Smckusick close(tt); 6038870Smckusick } 6138870Smckusick } 6238870Smckusick (void) setpgrp(0, 0); 6338870Smckusick signal(SIGTSTP, SIG_IGN); 6438870Smckusick signal(SIGTTIN, SIG_IGN); 6538870Smckusick signal(SIGTTOU, SIG_IGN); 6638870Smckusick signal(SIGINT, SIG_IGN); 6738870Smckusick signal(SIGQUIT, SIG_IGN); 6838870Smckusick signal(SIGTERM, SIG_IGN); 6938870Smckusick signal(SIGHUP, SIG_IGN); 7038870Smckusick } 7138870Smckusick if (argc != 2 || (cnt = atoi(argv[1])) <= 0 || cnt > 20) 7238870Smckusick cnt = 1; 7338870Smckusick for (i = 1; i < cnt; i++) 7438870Smckusick if (fork() == 0) 7538870Smckusick break; 7639865Smckusick async_daemon(); /* Never returns */ 7739865Smckusick exit(1); 7838870Smckusick } 79