summaryrefslogtreecommitdiffstats
path: root/discover/pb-discover.c
blob: 024cb303fb9f6da4dfb4dd0204c59d12425a213a (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

#include <stdlib.h>
#include <signal.h>

#include "udev.h"
#include "discover-server.h"
#include "device-handler.h"
#include "waiter.h"
#include "log.h"

static int running;

void sigint_handler(int signum)
{
	running = 0;
}

int main(void)
{
	struct device_handler *handler;
	struct discover_server *server;
	struct udev *udev;

	/* we look for closed sockets when we write, so ignore SIGPIPE */
	signal(SIGPIPE, SIG_IGN);

	signal(SIGINT, sigint_handler);

	server = discover_server_init();
	if (!server)
		return EXIT_FAILURE;

	handler = device_handler_init(server);
	if (!handler)
		return EXIT_FAILURE;

	discover_server_set_device_source(server, handler);

	udev = udev_init(handler);
	if (!udev)
		return EXIT_FAILURE;

	for (running = 1; running;) {
		if (waiter_poll())
			break;
	}

	device_handler_destroy(handler);


	return EXIT_SUCCESS;
}
OpenPOWER on IntegriCloud