I've discovered that the agetty login process on the serial port of a Dell Latitude e7240 Ultrabook gets very confused when the laptop is docked or undocked. It repeats an error message that "/dev/ttyS0: not a tty". Even weirder, it seems to be right. Checking with the setserial command, ttyS0 doesn't even have a UART type. This is likely a bug in the Linux kernel as that should never happen. Fortunately, I can fix it by running,

Code:
sudo setserial /dev/ttyS0 autoconfig
However, I'd like to make it automatic. Where are the scripts that are run whenever a machine is docked/undocked?

Thanks!