[systemd-devel] Preventing application termination if ttyPATH device is not found

Mantas Mikulėnas grawity at gmail.com
Thu Feb 28 07:20:35 UTC 2019


On Thu, Feb 28, 2019 at 8:45 AM Dhananjay Patil <Dhananjay.Patil at ltts.com>
wrote:

> Hi All,
>
>
>
> I have following question:
>
>    1. Is there any way to prevent application from termination  if
>     ttyPATH device not found
>    2. How to set Standard output device as pseudo terminal device for
>    service? So when user login using ssh/telnet standard output will be
>    available on this device
>
>
You cannot assign the telnet pty device dynamically, if that's what you're
trying to achieve.

Most of the time (probably all of the time), your service will start before
any telnet connections or ptys exist yet. So a service has
TTYPath=/dev/pts/0, systemd has only two choices: either fail the service
entirely, or start it with another stdout (e.g. null or journal).

But once the service is already running, systemd *cannot* change the
service's standard output – only the process itself can change its stdout.
You cannot have a .service that starts without a tty but automagically
"attaches" to /dev/pts/0 as soon as you telnet into the system.

You'll need additional software to really achieve this. For example, you
could use StandardOutput=journal (the default) but add a custom syslogd
daemon that reads journal messages containing your printfs and duplicates
them across all existing ptys. (AFAIK, some existing syslog daemons can
already do this.)

Or just manually run `journalctl --follow --unit=myapp.service` after
telnetting in.

-- 
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190228/a9d0fc0b/attachment.html>


More information about the systemd-devel mailing list