- char buf[BUFSIZ];
- FILE *log, *prog;
- int logf, inf, i, done, pid, tty;
-
- extern int errno;
- extern char *sys_errlist[];
-
- int nfds = getdtablesize();
-
- whoami = argv[0];
-
- setreuid(0);
- signal(SIGCHLD, cleanup);
-
- sprintf(buf, "%s/moira.log", SMS_DIR);
- logf = open(buf, O_CREAT|O_WRONLY|O_APPEND, 0640);
- if (logf<0) {
- perror(buf);
- exit(1);
- }
- inf = open("/dev/null", O_RDONLY , 0);
- if (inf < 0) {
- perror("/dev/null");
- exit(1);
- }
- pipe(rdpipe);
- if (fork()) {
- exit(0);
- }
- chdir("/");
- close(0);
- close(1);
- close(2);
- dup2(inf, 0);
- dup2(inf, 1);
- dup2(inf, 2);
-
- tty = open("/dev/tty");
- ioctl(tty, TIOCNOTTY, 0);
- close(tty);
- sprintf(buf, "%s/%s", BIN_DIR, PROG);
-
- if ((pid = fork()) == 0) {
-
- dup2(inf, 0);
- dup2(rdpipe[1], 1);
- dup2(1,2);
- for (i = 3; i <nfds; i++) close(i);
- execl(buf, PROG, 0);
- perror("cannot run moirad");
- exit(1);
- }
- if (pid<0) {
- perror("moira_starter");
- exit(1);
- }
+ char buf[BUFSIZ];
+ FILE *log, *prog;
+ int logf, inf, i, done, pid;
+ struct rlimit rl;