[systemd-devel] How to get systemd to leave a USB serial console session alone when hadware is pulled?

Greg KH greg at kroah.com
Wed May 15 20:48:04 PDT 2013


On Wed, May 15, 2013 at 04:32:12PM -0700, Kaz Kylheku wrote:
> 
> Hi all,
> 
> I have a system that is configured to have a ttyUSB0 as a console.
> 
> To improve this, I patched the Linux kernel to create a cool feature:
> when a USB Converter is removed, although the `/dev/ttyUSB<n>` entry
> disappears, existing file descriptors which have that tty device open
> are undisturbed. Processes that are blocked on a tty read do not so
> much
> as wake up. Writes go to the bit bucket. When hardware re-appears and
> `/dev/ttyUSB<n>` comes back to life, those tty file descriptors are
> re-attached, and I/O nicely resumes. (Even if different hardware is
> plugged in: remove a PL2303 and plug in an FTDI, and your tty is
> back.)

Where is this patch you have created?  This isn't something you rally
want to do, as plugging in a different tty device, you don't want to
resume sending data to it without letting userspace know that something
changed.

And why isn't userspace paying attention to the HANGUP signal we send
it?

> What's wrecking things is systemd:
> 
> 1. systemd does not serve up an `agetty` on the port,
>   unless the hardware is already inserted before the system
>   boots up.

That is as planned.

> 2. If  the hardware is pulled, then systemd kills the session.
>   It kills agetty and all its progeny, whether there is a logged
>   in shell session on the console or not.

systemd should kill the session, it is working correctly.

> 3. Thirdly, systemd will not serve up `agetty` when the hardware is
>   re-inserted even if it previously started `agetty` on that port.
>   It notices the removal, but not the reinsertion.

As you seem to have changed the kernel to not handle the reinsertion,
how can it know this?

> How can we configure systemd not to kill the session if the tty device
> is removed, but only to ensure that all console devices have
> an agetty?

As you are doing something very dangerous and not at all recommended,
you really are on your own here.  You get to keep the pieces when it
breaks down, sorry.

Best of luck,

greg k-h


More information about the systemd-devel mailing list