]> git.neil.brown.name Git - metad.git/blob - metad.c
9586578c4159faec2f8d029378e7861cfecf0b90
[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 char **gargv;
9
10 int main(int argc, char *argv[])
11 {
12     gargv = argv;
13
14     {
15         int ttyfd = open("/dev/tty", 2, 0);
16         if (ttyfd >= 0) {
17             ioctl(ttyfd, TIOCNOTTY, NULL);
18             close(ttyfd);
19         }
20     }
21
22     /* FIXME should make sure stdin/stdout/stderr are open to something */
23     service_init();
24     control_init();
25     errors_to(ERROR_SYSLOG, NULL);
26     read_config(services, argv[1]);
27     if (strcmp(argv[0], "metad-restart")==0) {
28         loadstate(0);
29         open("/dev/null", O_RDONLY);
30     }
31     main_loop();
32     exit(0);
33 }