<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 28, 2019 at 8:45 AM Dhananjay Patil <<a href="mailto:Dhananjay.Patil@ltts.com">Dhananjay.Patil@ltts.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_-1689031687603554199WordSection1">
<p class="MsoNormal">Hi All,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have following question:<u></u><u></u></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoNormal" style="margin-left:0in">Is there any way to prevent application from termination if ttyPATH device not found<u></u><u></u></li><li class="MsoNormal" style="margin-left:0in">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<u></u><u></u></li></ol>
<p class="gmail-m_-1689031687603554199MsoListParagraph"><u></u></p></div></div></blockquote><div><br></div><div>You cannot assign the telnet pty device dynamically, if that's what you're trying to achieve.</div><div><br></div><div>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).</div><div><br></div><div>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.</div><div><br></div><div>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.)</div><div><br></div><div>Or just manually run `journalctl --follow --unit=myapp.service` after telnetting in.</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>