Add signal handler stopping
authorTae-Young Chung <ty83.chung@samsung.com>
Tue, 25 Jun 2024 06:51:30 +0000 (15:51 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Tue, 25 Jun 2024 06:51:30 +0000 (15:51 +0900)
Change-Id: I46825867b78620fed18e0453417b7921cbc12ac3
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
test/services/smartpointer.cpp

index 47245e7c8f8c97dc6c8108ebdd5c81fd66a2e335..bb7b13e114fb4a2dc1f9f1bf33c0559f80911bd6 100644 (file)
@@ -27,8 +27,6 @@
 using namespace testing;
 using namespace std;
 
-
-
 // A part of PoseVector should be moved to a common header.
 struct Point3f
 {
@@ -42,6 +40,14 @@ struct Context {
        bool is_loop_exit = false;
 };
 
+static Context context {};
+
+static void signalCallbackHandler(int signum)
+{
+       cout << "Terminating..." << endl;
+       context.is_loop_exit = true;
+}
+
 void user_callback(void *user_data)
 {
        Context *context = static_cast<Context *>(user_data);
@@ -73,8 +79,7 @@ void data_feeder_cb(unsigned char *buffer, unsigned int width, unsigned int heig
 
 int main(const int argc, const char *argv[])
 {
-       Context context {};
-
+       signal(SIGINT, signalCallbackHandler);
        singleo_service_create("service=smart_pointer, input_feed=camera, camera_id=4, fps=30, async=0",
                                                                         &context.handle);