Hi
On Tue, Mar 10, 2015 at 8:56 PM, <[email protected]> wrote:
> From: Lucas De Marchi <[email protected]>
>
> If we don't check the error of the child process, systemd-vconsole-setup
> would exit with 0 even if it could not really setup the console.
>
> For a simple test, move loadkeys elsewhere and execute
> systemd-vconsole-setup:
>
> [root@localhost ~]# strace -f -e execve
> /usr/lib/systemd/systemd-vconsole-setup
> execve("/usr/lib/systemd/systemd-vconsole-setup",
> ["/usr/lib/systemd/systemd-vconsol"...], [/* 15 vars */]) = 0
> Process 171 attached
> [pid 171] execve("/usr/bin/loadkeys", ["/usr/bin/loadkeys", "-q",
> "-C", "/dev/tty0", "br-abnt2"], [/* 15 vars */]) = -1 ENOENT (No such file or
> directory)
> [pid 171] +++ exited with 1 +++
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=171,
> si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
> +++ exited with 0 +++
>
> Now systemd-vconsole-setup exits with EXIT_FAILURE if the child failed
> for whatever reason.
> ---
> src/vconsole/vconsole-setup.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
> index bf681d9..601ca4a 100644
> --- a/src/vconsole/vconsole-setup.c
> +++ b/src/vconsole/vconsole-setup.c
> @@ -304,8 +304,12 @@ int main(int argc, char **argv) {
> return EXIT_FAILURE;
> }
>
> - if (font_pid > 0)
> - wait_for_terminate_and_warn(KBD_SETFONT, font_pid, true);
> + if (font_pid > 0) {
> + r = wait_for_terminate_and_warn(KBD_SETFONT, font_pid, true);
> + if (r != 0)
> + return EXIT_FAILURE;
> + }
> +
Looks mostly good. However, I'd prefer if we continue on "r > 0" but
remember the error for later. This way, we still try loading the right
keymap even though the font might have failed.
Thanks
David
>
> r = keymap_load(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid);
> if (r < 0) {
> @@ -313,10 +317,13 @@ int main(int argc, char **argv) {
> return EXIT_FAILURE;
> }
>
> - if (keymap_pid > 0)
> - wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid, true);
> + if (keymap_pid > 0) {
> + r = wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid,
> true);
> + if (r != 0)
> + return EXIT_FAILURE;
> + }
>
> - /* Only copy the font when we started setfont successfully */
> + /* Only copy the font when we executed setfont successfully */
> if (font_copy && font_pid > 0)
> font_copy_to_all_vcs(fd);
>
> --
> 2.3.2
>
> _______________________________________________
> systemd-devel mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel