Commit 8f8083b9 authored by Wim Taymans's avatar Wim Taymans
Browse files

examples: add signal handlers to quit nicely

parent 8e366a17
......@@ -24,7 +24,7 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <signal.h>
#include <spa/utils/result.h>
#include <spa/param/video/format-utils.h>
......@@ -397,6 +397,12 @@ static int build_format(struct data *data, struct spa_pod_builder *b, const stru
return 2;
static void do_quit(void *userdata, int signal_number)
struct data *data = userdata;
int main(int argc, char *argv[])
struct data data = { 0, };
......@@ -410,6 +416,9 @@ int main(int argc, char *argv[])
/* create a main loop */
data.loop = pw_main_loop_new(NULL);
pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGINT, do_quit, &data);
pw_loop_add_signal(pw_main_loop_get_loop(data.loop), SIGTERM, do_quit, &data);
/* create a simple stream, the simple stream manages to core and remote
* objects for you if you don't need to deal with them
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment