]> granicus.if.org Git - procps-ng/commitdiff
top: modify semaphore destruction for separate threads
authorJim Warner <james.warner@comcast.net>
Tue, 21 Sep 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sun, 26 Sep 2021 04:47:21 +0000 (14:47 +1000)
This commit just ensures that at program end all those
semaphores are removed in the same order for symmetry.
From thread's view of importance, we do least to most.

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 6348ac9c41564a83cdcf5cd01f81ca36d02fec38..50e0a11a171190968d728bc33d3b13d327ae0658 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -439,14 +439,14 @@ static void bye_bye (const char *str) {
 #ifdef THREADED_CPU
       pthread_cancel(Thread_id_cpus);
       pthread_join(Thread_id_cpus, NULL);
-      sem_destroy(&Semaphore_cpus_beg);
       sem_destroy(&Semaphore_cpus_end);
+      sem_destroy(&Semaphore_cpus_beg);
 #endif
 #ifdef THREADED_MEM
       pthread_cancel(Thread_id_memory);
       pthread_join(Thread_id_memory, NULL);
-      sem_destroy(&Semaphore_memory_beg);
       sem_destroy(&Semaphore_memory_end);
+      sem_destroy(&Semaphore_memory_beg);
 #endif
 #ifdef THREADED_TSK
       pthread_cancel(Thread_id_tasks);