From: Ray Strode Date: Thu, 5 Mar 2009 19:38:28 +0000 (-0500) Subject: Allow -1 to get passed to ply-terminal-session X-Git-Tag: 0.7.0~209 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c758b71face1278029a630f8dd3d8322f3c9b24b;p=thirdparty%2Fplymouth.git Allow -1 to get passed to ply-terminal-session This is coming from the drop-nash branch. It lets the caller of plymouth not have to create a pty master. --- diff --git a/src/libply/ply-terminal-session.c b/src/libply/ply-terminal-session.c index 1b491982..82e0c00a 100644 --- a/src/libply/ply-terminal-session.c +++ b/src/libply/ply-terminal-session.c @@ -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");