[gnome-panel] menu: redirect child stdout/stderr to journal
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] menu: redirect child stdout/stderr to journal
- Date: Sun, 28 Jan 2018 22:19:51 +0000 (UTC)
commit 5ce96e7a5608a7a4b96e2de1c6f8be7037f2c391
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Jan 26 14:28:29 2018 +0200
menu: redirect child stdout/stderr to journal
configure.ac | 2 ++
modules/menu/gp-menu-utils.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d08eb9d..aa079f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,7 @@ LIBWNCK_REQUIRED=3.4.6
LIBGNOME_MENU_REQUIRED=3.7.90
LIBECAL_REQUIRED=3.5.3
LIBEDATASERVER_REQUIRED=3.5.3
+LIBSYSTEMD_REQUIRED=230
CAIRO_REQUIRED=1.0.0
GWEATHER_REQUIRED=3.17.1
DCONF_REQUIRED=0.13.4
@@ -159,6 +160,7 @@ PKG_CHECK_MODULES([MENU], [
gio-unix-2.0 >= $GLIB_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
libgnome-menu-3.0 >= $LIBGNOME_MENU_REQUIRED
+ libsystemd >= $LIBSYSTEMD_REQUIRED
])
PKG_CHECK_MODULES([NOTIFICATION_AREA], [
diff --git a/modules/menu/gp-menu-utils.c b/modules/menu/gp-menu-utils.c
index 2395976..5de05f7 100644
--- a/modules/menu/gp-menu-utils.c
+++ b/modules/menu/gp-menu-utils.c
@@ -19,10 +19,37 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <systemd/sd-journal.h>
#include "gp-menu-utils.h"
static void
+child_setup (gpointer user_data)
+{
+ GAppInfo *info;
+ const gchar *id;
+ gint stdout_fd;
+ gint stderr_fd;
+
+ info = G_APP_INFO (user_data);
+ id = g_app_info_get_id (info);
+
+ stdout_fd = sd_journal_stream_fd (id, LOG_INFO, FALSE);
+ if (stdout_fd >= 0)
+ {
+ dup2 (stdout_fd, STDOUT_FILENO);
+ close (stdout_fd);
+ }
+
+ stderr_fd = sd_journal_stream_fd (id, LOG_WARNING, FALSE);
+ if (stderr_fd >= 0)
+ {
+ dup2 (stderr_fd, STDERR_FILENO);
+ close (stderr_fd);
+ }
+}
+
+static void
pid_cb (GDesktopAppInfo *info,
GPid pid,
gpointer user_data)
@@ -41,7 +68,7 @@ gp_menu_launch_app_info (GDesktopAppInfo *app_info)
error = NULL;
ret = g_desktop_app_info_launch_uris_as_manager (app_info, NULL, NULL,
- flags, NULL, NULL,
+ flags, child_setup, app_info,
pid_cb, NULL,
&error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]