Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Maintenance:4185
plymouth.openSUSE_Leap_42.1_Update
0001-let-it-become-a-real-daemon.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-let-it-become-a-real-daemon.patch of Package plymouth.openSUSE_Leap_42.1_Update
Related to bnc#892526 -- let plymouthd become a real daemon that is it should use its own session with the help of the system call setsid(2). Also avoid an EBUSY on ioctl TIOCCONS if a former plymouthd had failed. And a crash or termination may restore not only the current virtual console but also any serial console as well restore the system console. --- plymouth-0.9.0/src/libply-splash-core/ply-device-manager.c | 9 ++ plymouth-0.9.0/src/libply-splash-core/ply-device-manager.h | 1 plymouth-0.9.0/src/libply/ply-terminal-session.c | 7 ++ plymouth-0.9.0/src/libply/ply-utils.c | 2 plymouth-0.9.0/src/main.c | 42 +++++++------ 5 files changed, 43 insertions(+), 18 deletions(-) Index: plymouth-0.9.0/src/libply-splash-core/ply-device-manager.c =================================================================== --- plymouth-0.9.0.orig/src/libply-splash-core/ply-device-manager.c +++ plymouth-0.9.0/src/libply-splash-core/ply-device-manager.c @@ -933,3 +933,12 @@ ply_device_manager_deactivate_keyboards node = next_node; } } + +void +ply_close_all_terminals (ply_device_manager_t *manager) +{ + ply_hashtable_foreach (manager->terminals, + (ply_hashtable_foreach_func_t *) + ply_terminal_close, + manager); +} Index: plymouth-0.9.0/src/libply-splash-core/ply-device-manager.h =================================================================== --- plymouth-0.9.0.orig/src/libply-splash-core/ply-device-manager.h +++ plymouth-0.9.0/src/libply-splash-core/ply-device-manager.h @@ -49,6 +49,7 @@ void ply_device_manager_deactivate_keybo void ply_device_manager_activate_renderers (ply_device_manager_t *manager); void ply_device_manager_deactivate_renderers (ply_device_manager_t *manager); ply_terminal_t *ply_device_manager_get_default_terminal (ply_device_manager_t *manager); +void ply_close_all_terminals (ply_device_manager_t *manager); #endif Index: plymouth-0.9.0/src/libply/ply-utils.c =================================================================== --- plymouth-0.9.0.orig/src/libply/ply-utils.c +++ plymouth-0.9.0/src/libply/ply-utils.c @@ -77,6 +77,7 @@ static int errno_stack[PLY_ERRNO_STACK_SIZE]; static int errno_stack_position = 0; +static bool inChild = false; bool ply_open_unidirectional_pipe (int *sender_fd, @@ -797,6 +798,7 @@ ply_create_daemon (void) { int read_error = errno; int status; + inChild = true; if (waitpid (pid, &status, WNOHANG) <= 0) { @@ -843,6 +845,9 @@ ply_detach_daemon (ply_daemon_handle_t * close (sender_fd); free (handle); + if (inChild) + setsid(); + return true; } Index: plymouth-0.9.0/src/libply/ply-terminal-session.c =================================================================== --- plymouth-0.9.0.orig/src/libply/ply-terminal-session.c +++ plymouth-0.9.0/src/libply/ply-terminal-session.c @@ -187,6 +187,13 @@ ply_terminal_session_redirect_console (p assert (terminal_name != NULL); + fd = open ("/dev/console", O_RDWR | O_NOCTTY); + if (fd >= 0) + { + ioctl (fd, TIOCCONS); /* Undo any current map if any */ + close (fd); + } + fd = open (terminal_name, O_RDWR | O_NOCTTY); if (fd < 0) Index: plymouth-0.9.0/src/main.c =================================================================== --- plymouth-0.9.0.orig/src/main.c +++ plymouth-0.9.0/src/main.c @@ -1042,6 +1042,7 @@ on_seat_added (state_t *state, } +static ply_device_manager_t *manager; static void load_devices (state_t *state, ply_device_manager_flags_t flags) @@ -1049,6 +1050,8 @@ load_devices (state_t state->device_manager = ply_device_manager_new (state->default_tty, flags); state->local_console_terminal = ply_device_manager_get_default_terminal (state->device_manager); + manager = state->device_manager; + ply_device_manager_watch_seats (state->device_manager, (ply_seat_added_handler_t) on_seat_added, @@ -1077,6 +1080,7 @@ quit_splash (state_t *state) ply_trace ("Not retaining splash, so deallocating VT"); ply_terminal_deactivate_vt (state->local_console_terminal); ply_terminal_close (state->local_console_terminal); + ply_close_all_terminals (state->device_manager); } } @@ -2075,25 +2079,22 @@ dump_debug_buffer_to_file (void) #include <termios.h> #include <unistd.h> static void -on_crash (int signum) +dosigaction (int signum) { - struct termios term_attributes; int fd; - fd = open ("/dev/tty1", O_RDWR | O_NOCTTY); - if (fd < 0) fd = open ("/dev/hvc0", O_RDWR | O_NOCTTY); - - ioctl (fd, KDSETMODE, KD_TEXT); - - tcgetattr (fd, &term_attributes); - - term_attributes.c_iflag |= BRKINT | IGNPAR | ICRNL | IXON; - term_attributes.c_oflag |= OPOST; - term_attributes.c_lflag |= ECHO | ICANON | ISIG | IEXTEN; - - tcsetattr (fd, TCSAFLUSH, &term_attributes); + if (manager) + { + ply_device_manager_deactivate_keyboards (manager); + ply_close_all_terminals (manager); + } - close (fd); + fd = open ("/dev/console", O_RDWR | O_NOCTTY); + if (fd >= 0) + { + ioctl (fd, TIOCCONS); /* Undo any current map if any */ + close (fd); + } if (debug_buffer != NULL) { @@ -2108,7 +2109,6 @@ on_crash (int signum) pid_file = NULL; } - signal (signum, SIG_DFL); raise(signum); } @@ -2145,6 +2145,7 @@ main (int argc, char *kernel_command_line = NULL; char *tty = NULL; ply_device_manager_flags_t device_manager_flags = PLY_DEVICE_MANAGER_FLAGS_NONE; + struct sigaction sa; state.start_time = ply_get_timestamp (); state.command_parser = ply_command_parser_new ("plymouthd", "Splash server"); @@ -2256,8 +2257,13 @@ main (int argc, if (debug) debug_buffer = ply_buffer_new (); - signal (SIGABRT, on_crash); - signal (SIGSEGV, on_crash); + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESETHAND; + sa.sa_handler = dosigaction; + sigaction (SIGHUP, &sa, NULL); + sigaction (SIGTERM, &sa, NULL); + sigaction (SIGABRT, &sa, NULL); + sigaction (SIGSEGV, &sa, NULL); /* before do anything we need to make sure we have a working * environment.
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor