]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Drop PLY_DAEMON_ONLY macro and just look at asdaemon
authorRay Strode <rstrode@redhat.com>
Wed, 4 Jun 2008 01:33:56 +0000 (21:33 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 4 Jun 2008 01:33:56 +0000 (21:33 -0400)
Since we no longer support starting a session, only
attaching to an existing one, we can just key off
asdaemon to know whether to run the terminal session
code.

src/main.c

index 3a22e88618e4cf351770d99677e2714c9f188e03..6f96c0249bfdc295754f735b7f7e807652b3e91b 100644 (file)
 #define PLY_MAX_COMMAND_LINE_SIZE 512
 #endif
 
-#ifndef PLY_DAEMON_ONLY
-#define PLY_DAEMON_ONLY(state) ((state)->ptmx != -1)
-#endif
-
 typedef struct
 {
   ply_event_loop_t *loop;
@@ -261,28 +257,25 @@ attach_to_running_session (state_t *state)
   flags |= PLY_TERMINAL_SESSION_FLAGS_REDIRECT_CONSOLE;
   flags |= PLY_TERMINAL_SESSION_FLAGS_CHANGE_ROOT_TO_CURRENT_DIRECTORY;
 
-  if (PLY_DAEMON_ONLY(state))
+  ply_trace ("creating terminal session for current terminal");
+  session = ply_terminal_session_new (NULL);
+  ply_trace ("attaching terminal session to event loop");
+  ply_terminal_session_attach_to_event_loop (session, state->loop);
+
+  if (!ply_terminal_session_attach (session, flags,
+                                 (ply_terminal_session_output_handler_t)
+                                 on_session_output,
+                                 (ply_terminal_session_done_handler_t)
+                                 on_session_finished,
+                                 state->ptmx,
+                                 state))
     {
-      ply_trace ("creating terminal session for current terminal");
-      session = ply_terminal_session_new (NULL);
-      ply_trace ("attaching terminal session to event loop");
-      ply_terminal_session_attach_to_event_loop (session, state->loop);
-
-      if (!ply_terminal_session_attach (session, flags,
-                                     (ply_terminal_session_output_handler_t)
-                                     on_session_output,
-                                     (ply_terminal_session_done_handler_t)
-                                     on_session_finished,
-                                     state->ptmx,
-                                     state))
-        {
-          ply_save_errno ();
-          ply_terminal_session_free (session);
-          ply_buffer_free (state->boot_buffer);
-          state->boot_buffer = NULL;
-          ply_restore_errno ();
-          return NULL;
-        }
+      ply_save_errno ();
+      ply_terminal_session_free (session);
+      ply_buffer_free (state->boot_buffer);
+      state->boot_buffer = NULL;
+      ply_restore_errno ();
+      return NULL;
     }
 
   return session;
@@ -613,15 +606,15 @@ main (int    argc,
 
   state.boot_buffer = ply_buffer_new ();
 
-  state.session = attach_to_running_session (&state);
-
-  if (state.session == NULL)
+  if (asdaemon)
     {
-      if (asdaemon)
-        ply_error ("could not create session: %m");
-      else
-        ply_error ("could not run '%s': %m", argv[1]);
-      return EX_UNAVAILABLE;
+      state.session = attach_to_running_session (&state);
+
+      if (state.session == NULL)
+        {
+          ply_error ("could not create session: %m");
+          return EX_UNAVAILABLE;
+        }
     }
 
   state.boot_server = start_boot_server (&state);