]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Allow -1 to get passed to ply-terminal-session
authorRay Strode <rstrode@redhat.com>
Thu, 5 Mar 2009 19:38:28 +0000 (14:38 -0500)
committerRay Strode <rstrode@redhat.com>
Thu, 5 Mar 2009 19:38:28 +0000 (14:38 -0500)
This is coming from the drop-nash branch.  It lets
the caller of plymouth not have to create a pty master.

src/libply/ply-terminal-session.c

index 1b491982c725d63a5eddcd47dd8f60db0cd02257..82e0c00a9346a7904028286ce05c552fce647bbe 100644 (file)
@@ -308,12 +308,24 @@ ply_terminal_session_attach (ply_terminal_session_t               *session,
   assert (session->loop != NULL);
   assert (!session->is_running);
   assert (session->done_handler == NULL);
-  assert (ptmx >= 0);
 
   should_redirect_console = 
     (flags & PLY_TERMINAL_SESSION_FLAGS_REDIRECT_CONSOLE) != 0;
 
-  ply_terminal_set_fd(session->terminal, ptmx);
+  if (ptmx >= 0)
+    {
+      ply_trace ("ptmx passed in, using it");
+      ply_terminal_set_fd(session->terminal, ptmx);
+    }
+  else
+    {
+      ply_trace ("ptmx not passed in, creating one");
+      if (!ply_terminal_create_device (session->terminal))
+        {
+          ply_trace ("could not create pseudo-terminal: %m");
+          return false;
+        }
+    }
 
   if (should_redirect_console)
     ply_trace ("redirecting system console to terminal device");