mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-03 08:00:15 +01:00
tools: terminate the example server correctly on SIGINT
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
802dfd4ca6
commit
31581eb110
1 changed files with 10 additions and 1 deletions
|
|
@ -35,6 +35,12 @@
|
|||
#include "src/util-mem.h"
|
||||
#include "src/util-strings.h"
|
||||
|
||||
static bool stop = false;
|
||||
|
||||
static void sighandler(int signal) {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char SOCKETNAME[] = "eis.socket";
|
||||
|
|
@ -49,6 +55,7 @@ int main(int argc, char **argv)
|
|||
|
||||
/* This should be handled by libeis */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGINT, sighandler);
|
||||
|
||||
int rc = eis_socket_init(eis, SOCKETNAME);
|
||||
if (rc != 0) {
|
||||
|
|
@ -64,7 +71,7 @@ int main(int argc, char **argv)
|
|||
.revents = 0,
|
||||
};
|
||||
|
||||
while (poll(&fds, 1, -1) > -1) {
|
||||
while (!stop && poll(&fds, 1, -1) > -1) {
|
||||
eis_dispatch(eis);
|
||||
|
||||
while (true) {
|
||||
|
|
@ -121,5 +128,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
eis_unref(eis);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue