[glib/wip/smcv/gio-launch-desktop-sd-journal] gio-launch-desktop: Only replace fds that point to the Journal
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/gio-launch-desktop-sd-journal] gio-launch-desktop: Only replace fds that point to the Journal
- Date: Mon, 25 Jul 2022 09:22:20 +0000 (UTC)
commit 94e05f7f289069aaf8ad894d3308eb5f324f12c9
Author: Simon McVittie <smcv collabora com>
Date: Mon Jul 25 09:59:17 2022 +0100
gio-launch-desktop: Only replace fds that point to the Journal
If stdout is the Journal but stderr is not, then we probably only want
to redirect stdout, or vice versa.
Signed-off-by: Simon McVittie <smcv collabora com>
gio/gio-launch-desktop.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gio/gio-launch-desktop.c b/gio/gio-launch-desktop.c
index 9ed6712f74..29bf9d5d42 100644
--- a/gio/gio-launch-desktop.c
+++ b/gio/gio-launch-desktop.c
@@ -187,11 +187,16 @@ fail:
static void
set_up_journal (const char *argv1)
{
+ int stdout_is_journal;
+ int stderr_is_journal;
const char *identifier;
const char *slash;
int fd;
- if (!_g_fd_is_journal (STDOUT_FILENO) && !_g_fd_is_journal (STDERR_FILENO))
+ stdout_is_journal = _g_fd_is_journal (STDOUT_FILENO);
+ stderr_is_journal = _g_fd_is_journal (STDERR_FILENO);
+
+ if (!stdout_is_journal && !stderr_is_journal)
return;
identifier = getenv ("GIO_LAUNCHED_DESKTOP_FILE");
@@ -210,14 +215,14 @@ set_up_journal (const char *argv1)
if (fd < 0)
return;
- if (dup2 (fd, STDOUT_FILENO) != STDOUT_FILENO)
+ if (stdout_is_journal && dup2 (fd, STDOUT_FILENO) != STDOUT_FILENO)
fprintf (stderr,
"gio-launch-desktop[%d]: Unable to redirect \"%s\" to Journal: %s",
getpid (),
identifier,
strerror (errno));
- if (dup2 (fd, STDERR_FILENO) != STDERR_FILENO)
+ if (stderr_is_journal && dup2 (fd, STDERR_FILENO) != STDERR_FILENO)
fprintf (stderr,
"gio-launch-desktop[%d]: Unable to redirect \"%s\" to Journal: %s",
getpid (),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]