Check tgkill() result 24/85324/3
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 24 Aug 2016 14:45:21 +0000 (16:45 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 30 Aug 2016 14:49:36 +0000 (07:49 -0700)
tgkill() returns an error if we're attempting to send a signal to non-existing
thread. If this is the case don't increment the sent signals counter.

Change-Id: I1cf10fe5a056e7715660b02647dfdef4a6406ff3

src/client/client-security-manager.cpp

index f972274..e8e854a 100644 (file)
@@ -497,9 +497,9 @@ inline static uid_t gettid()
     return syscall(SYS_gettid);
 }
 
-inline static void tgkill(pid_t tgid, uid_t tid)
+inline static bool tgkill(pid_t tgid, uid_t tid)
 {
-    syscall(SYS_tgkill, tgid, tid, SIGUSR1);
+    return syscall(SYS_tgkill, tgid, tid, SIGUSR1) == 0;
 }
 
 inline static int label_for_self_internal()
@@ -593,8 +593,12 @@ static inline int security_manager_sync_threads_internal(const char *app_name)
     std::atomic_thread_fence(std::memory_order_release);
 
     for (auto const& t_pair : g_tid_attr_current_map) {
+        if (!tgkill(cur_pid, t_pair.first)) {
+            LogWarning("Error in tgkill()");
+            continue;
+        }
+
         sent_signals_count++;
-        tgkill(cur_pid, t_pair.first);
     }
 
     LogDebug("sent_signals_count: " << sent_signals_count);