mirror of
https://github.com/brl/mutter.git
synced 2025-08-13 20:04:51 +00:00
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
This commit is contained in:
@@ -1507,6 +1507,8 @@ meta_wayland_init (void)
|
|||||||
if (compositor->drm_fd >= 0)
|
if (compositor->drm_fd >= 0)
|
||||||
{
|
{
|
||||||
GError *error;
|
GError *error;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
int fd;
|
||||||
|
|
||||||
/* Running on bare metal, let's initalize DRM master and VT handling */
|
/* Running on bare metal, let's initalize DRM master and VT handling */
|
||||||
compositor->tty = meta_tty_new ();
|
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 ("Failed to become DRM master: %s", error->message);
|
||||||
g_error_free (error);
|
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 ();
|
compositor->stage = meta_wayland_stage_new ();
|
||||||
|
Reference in New Issue
Block a user