]> git.neil.brown.name Git - metad.git/blob - metad.c
Assorted reformating
[metad.git] / metad.c
1
2 #include        "metad.h"
3 #include        <sys/ioctl.h>
4 #include        <sys/fcntl.h>
5 #ifdef SOLARIS
6 #include        <sys/termios.h>
7 #endif
8
9 char **gargv; /* used to pass args to 'restart' */
10
11 int main(int argc, char *argv[])
12 {
13         gargv = argv;
14
15         {
16                 int ttyfd = open("/dev/tty", 2, 0);
17                 if (ttyfd >= 0) {
18                         ioctl(ttyfd, TIOCNOTTY, NULL);
19                         close(ttyfd);
20                 }
21         }
22
23         /* FIXME should make sure stdin/stdout/stderr are open to something */
24         service_init();
25         control_init();
26         errors_to(ERROR_SYSLOG, NULL);
27         read_config(services, argv[1]);
28         if (strcmp(argv[0], "metad-restart")==0) {
29                 loadstate(0);
30                 open("/dev/null", O_RDONLY);
31         }
32         main_loop();
33         exit(0);
34 }