From 9abfc0ca8c79e0be68d240fcdfe3d75a730859d5 Mon Sep 17 00:00:00 2001 From: Casey Jao Date: Thu, 10 Aug 2017 08:29:58 -0700 Subject: [PATCH] Replaced up_get_clipboard() with a pidof hack. up_get_clipboard() is X-specific and segfaults on Wayland. We read "pidof" and check if a copy of update-notifier is already present as indicated by a space in the output. --- src/update-notifier.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/update-notifier.c b/src/update-notifier.c index 6837118..05eaab0 100644 --- a/src/update-notifier.c +++ b/src/update-notifier.c @@ -531,6 +531,22 @@ static GOptionEntry entries[] = }; int +check_if_running(void) +{ + char output[10]; + FILE *cmd = popen ("pidof update-notifier", "r"); + if (cmd) + { + fgets (output, 10, cmd); + return (strchr(output, ' ') != NULL); + } + else + { + return 1; + } +} + +int main (int argc, char **argv) { UpgradeNotifier *un; @@ -582,7 +598,7 @@ main (int argc, char **argv) } // check if it is running already - if (!up_get_clipboard ()) { + if (check_if_running()) { g_warning ("already running?"); return 1; } -- 2.11.0