[mutter/wip/wayland-display: 21/65] MetaWayland: redirect stdin/stdout/stderr when running on bare metal
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/wayland-display: 21/65] MetaWayland: redirect stdin/stdout/stderr when running on bare metal
- Date: Wed, 14 Aug 2013 16:45:17 +0000 (UTC)
commit b29d8046b0429ecf7a57f98c385f375349ceb9de
Author: Giovanni Campagna <gcampagn redhat com>
Date: Fri Aug 9 17:56:24 2013 +0200
MetaWayland: redirect stdin/stdout/stderr when running on bare metal
We need to spawn background processes for gnome-session and friends,
so we need to make sure they don't try to read or write from our
terminal.
https://bugzilla.gnome.org/show_bug.cgi?id=705861
src/wayland/meta-wayland.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 01ad437..8e716f2 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1507,6 +1507,8 @@ meta_wayland_init (void)
if (compositor->drm_fd >= 0)
{
GError *error;
+ char path[PATH_MAX];
+ int fd;
/* Running on bare metal, let's initalize DRM master and VT handling */
compositor->tty = meta_tty_new ();
@@ -1523,6 +1525,24 @@ meta_wayland_init (void)
g_error ("Failed to become DRM master: %s", error->message);
g_error_free (error);
}
+
+ /* Open a log in the home directory. This is necessary because otherwise
+ all background processes (such as gnome-session and children) get SIGTTOU
+ trying to write to the terminal.
+
+ Then close (</dev/null) stdin, so we don't get SIGTTIN or other crazy stuff.
+ */
+ snprintf(path, PATH_MAX, "%s/gnome-wayland.log", g_get_user_cache_dir ());
+ fd = open (path, O_WRONLY | O_APPEND | O_CREAT | O_TRUNC, 0600);
+ if (fd < 0)
+ fd = open ("/dev/null", O_WRONLY | O_NOCTTY, 0600);
+
+ dup2 (fd, STDOUT_FILENO);
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+
+ fd = open ("/dev/null", O_WRONLY | O_NOCTTY, 0600);
+ dup2 (fd, STDIN_FILENO);
}
compositor->stage = meta_wayland_stage_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]