diff options
| author | Ray Strode <rstrode@redhat.com> | 2007-05-23 14:29:14 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2007-05-23 14:29:14 -0400 |
| commit | 23aad9450761ff34aff7b5ddda2f98987cd3bdbb (patch) | |
| tree | ebbcd32daebc353eaa6b48909086d8870ad66c3e /src | |
| parent | a707efeca4306c9f07004679d6d487afbe9f2c4d (diff) | |
| download | plymouth-23aad9450761ff34aff7b5ddda2f98987cd3bdbb.tar.gz plymouth-23aad9450761ff34aff7b5ddda2f98987cd3bdbb.tar.xz plymouth-23aad9450761ff34aff7b5ddda2f98987cd3bdbb.zip | |
add start of a program to eat a sessions output
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 11 | ||||
| -rw-r--r-- | src/main.c | 81 |
2 files changed, 87 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index feef70c..267f46d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,12 +4,19 @@ INCLUDES = -I$(top_srcdir) \ plymouth_CFLAGS = plymouth_LDADD = -plymouth_SOURCES = ply-utils.h \ - ply-utils.c \ +plymouth_SOURCES = \ ply-list.h \ ply-list.c \ + ply-logger.h \ + ply-logger.c \ ply-event-loop.h \ ply-event-loop.c \ + ply-terminal.h \ + ply-terminal.c \ + ply-terminal-session.h \ + ply-terminal-session.c \ + ply-utils.h \ + ply-utils.c \ main.c noinst_PROGRAMS = plymouth @@ -1,7 +1,6 @@ -/* main.c - graphical boot splash screen +/* main.c - boot messages monitor * * Copyright (C) 2007 Red Hat, Inc - * All rights reserved. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -20,10 +19,86 @@ * * Written by: Ray Strode <rstrode@redhat.com> */ +#include "config.h" + +#include <stdlib.h> +#include <stdio.h> +#include <sysexits.h> + +#include "ply-event-loop.h" +#include "ply-logger.h" +#include "ply-terminal-session.h" +#include "ply-utils.h" + +typedef struct +{ + ply_event_loop_t *loop; + ply_terminal_session_t *session; +} state_t; + +static void +on_session_finished (state_t *state) +{ + ply_flush_log (); + ply_event_loop_exit (state->loop, 0); +} + +static ply_terminal_session_t * +spawn_session (state_t *state, + char **argv) +{ + ply_terminal_session_t *session; + ply_terminal_session_flags_t flags; + + flags = 0; + flags |= PLY_TERMINAL_SESSION_FLAGS_RUN_IN_PARENT; + flags |= PLY_TERMINAL_SESSION_FLAGS_LOOK_IN_PATH; + + session = ply_terminal_session_new ((const char * const *) argv); + ply_terminal_session_attach_to_event_loop (session, state->loop); + + if (!ply_terminal_session_run (session, flags, + (ply_terminal_session_done_handler_t) + on_session_finished, state)) + { + ply_save_errno (); + ply_terminal_session_free (session); + ply_restore_errno (); + return NULL; + } + + return session; +} + int main (int argc, char **argv) { - return 0; + state_t state; + int exit_code; + + if (argc <= 1) + { + ply_error ("%s other-command [other-command-args]", argv[0]); + return EX_USAGE; + } + + state.loop = ply_event_loop_new (); + state.session = spawn_session (&state, argv + 1); + + if (state.session == NULL) + { + ply_error ("could not run '%s': %m", argv[0]); + return EX_UNAVAILABLE; + } + + ply_terminal_session_start_logging (state.session); + exit_code = ply_event_loop_run (state.loop); + ply_terminal_session_stop_logging (state.session); + + ply_terminal_session_free (state.session); + ply_event_loop_free (state.loop); + + return exit_code; } /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ |
