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

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

#include <waiter/waiter.h>
#include <log/log.h>

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

static int running;

static void sigint_handler(int __attribute__((unused)) 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