blob: e2b78d0e4701670ffb64684ba59ec535e5760621 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
From 5a6b01aaeb109ef419ab021972a4225618b277ce Mon Sep 17 00:00:00 2001
From: Guido Falsi <madpilot@freebsd.org>
Date: Sun, 16 Nov 2025 12:14:37 +0100
Subject: [PATCH] Use pgrep in place of pidof
This also simplifies function logic.
Fixes: #38
---
src/gs-lock-plug.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index d0806f64..fce7bf15 100644
--- src/gs-lock-plug.c
+++ src/gs-lock-plug.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
+#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@@ -179,20 +180,11 @@ toggle_infobar_visibility (GSLockPlug *plug) {
static gboolean
process_is_running (const char *name) {
- int num_processes;
- gchar *command = g_strdup_printf ("pidof %s | wc -l", name);
- FILE *fp = popen (command, "r");
+ gchar *command = g_strdup_printf ("pgrep %s", name);
+ int rc = system (command);
g_free (command);
- if (fp == NULL)
- return FALSE;
-
- if (fscanf (fp, "%d", &num_processes) != 1)
- num_processes = 0;
-
- pclose (fp);
-
- if (num_processes > 0) {
+ if (WIFEXITED (rc) && WEXITSTATUS (rc) == 0) {
return TRUE;
} else {
return FALSE;
--
GitLab
|