blob: 92b3d3271972cbac989c621ae88ac4238650adbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/**
* @file
* @section AUTHORS
*
* Authors:
* Eamon Walsh <ewalsh@tycho.nsa.gov>
* Frank Rehberger <F.Rehberger@xtradyne.de>
*
* @section LICENSE
*
* This file is in the public domain.
*
* @section DESCRIPTION
*
* This is the main routine for the linpicker_server program.
* Nothing much here except initialization, select loop, and teardown.
*/
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include "common.h"
#include "fd.h"
#include "xen_backend.h"
#include "sys-queue.h"
#include "display.h"
#include "input.h"
#include "local.h"
static int timetodie;
/*
* Is called in case of process signals.
*/
static void
server_sighandler(int sig)
{
timetodie = 1;
}
/*
* Main
*/
int main (int argc, char *argv[])
{
struct sigaction sa = { .sa_handler = server_sighandler };
/* Set up sighandlers */
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
/* Open logfile */
if (fd_open_logfile(SERVER_LOG) < 0)
return 1;
/* Initialize subsystems */
if (local_init(argc, argv) < 0)
return 1;
if (display_initialize(&argc, &argv) < 0)
return 2;
if (input_initialize(argc, argv) < 0)
return 3;
if (xen_be_init() < 0)
return 4;
/* Enter select loop */
while (!timetodie && fd_run_select() == 0);
/* Shut down */
input_shutdown();
display_shutdown();
fd_shutdown();
return 0;
}
|