run: exit early in --pty if service failed
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Dec 2016 23:35:58 +0000 (00:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 3 Feb 2017 10:51:57 +0000 (11:51 +0100)
commit95f1d6bfecde60b245fae1ab0313b550201e7880
treeff2dd416a0a3aca340ecb7af786ba3d3734f487d
parent9182fb52acc5993a86b83c2fe4216a542cecf226
run: exit early in --pty if service failed

This reworks systemd-run so that in --pty mode we watch the unit state
the way we do it in --wait mode. Whenever we notice that the service is
in failed or inactive state finish right-away, but first write all
unwritten characters we can read from the master TTY device.

This makes sure that when the TTY service fails before it opens the
slave PTY device we properly notice that and exit early, so that borked
start parameters result in immediate systemd-run failure. Previously,
we'd not notice this at all, as a PTY slave that never was opened won't
result in POLLHUP events, and we'd hence simply keep reading from it
forever.

In essence, --pty now enables the same unit watching logic that --wait
enables. However, unless --wait is specified we won#t show the final
summary, hence the effective difference should be pretty minimal.

Fixes: #3915
src/run/run.c
src/shared/ptyfwd.c
src/shared/ptyfwd.h