[systemd-devel] [PATCH] core/main.c: only reopen /dev/console if we switch-root to a custom init

Lennart Poettering lennart at poettering.net
Fri Jul 13 04:59:07 PDT 2012


On Thu, 12.07.12 08:43, harald at redhat.com (harald at redhat.com) wrote:

Heya,

Hmm, I'd prefer if we'd still work fine if somebody invokes us with he
controlling TTY on /dev/console, like we did before this patch.

In an attempt to fix this I have now added code that sets SIGHUP to
SIG_IGN on both SIOCSCTTY and SIOCNOTTY. This should make sure that we
never catch a SIGHUP generated by detaching from the controlling
TTY. Could you check if this makes the problem go away, too?

Thanks!

> From: Harald Hoyer <harald at redhat.com>
> 
> ---
>  src/core/main.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/core/main.c b/src/core/main.c
> index 6f6b565..a7172c1 100644
> --- a/src/core/main.c
> +++ b/src/core/main.c
> @@ -1672,9 +1672,6 @@ finish:
>                   * rebooted while we do that */
>                  watchdog_close(true);
>  
> -                /* Reopen the console */
> -                make_console_stdio();
> -
>                  if (switch_root_dir) {
>                          r = switch_root(switch_root_dir);
>                          if (r < 0)
> @@ -1711,6 +1708,9 @@ finish:
>                          execv(args[0], (char* const*) args);
>                  }
>  
> +                /* Reopen the console */
> +                make_console_stdio();
> +
>                  /* Try the fallback, if there is any, without any
>                   * serialization. We pass the original argv[] and
>                   * envp[]. (Well, modulo the ordering changes due to


Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list