1

I'm trying to autostart an interactive C++ program at boot before TTY1 appears.

I have created a file called /etc/systemd/system/myapp.service with the following contents:

[Unit]
Description=myapp

[Service]
Type=oneshot
ExecStart=/home/xxx/myapp.exe start
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

And then ran

sudo systemctl enable myapp

Unfortunately, it doesn't work as expected. I can't interact with myapp, and I do not want TTY1 to appear until the program ends


UPDATE: My app now works before the TTY appears. /etc/systemd/system/myapp.service now contains:

[Unit]
Description=myapp
After=sysinit.target

[Service]
Type=oneshot
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start

[Install]
WantedBy=multi-user.target

But I still can't interact with my program.

0

1 Answer 1

1

I was able to interact with my program by adding a TTY StandardInput line to the systemd service, and disabling the TTY1 systemd service.

Here are the final contents of /etc/systemd/system/myapp.service:

[Unit]
Description=myapp
After=sysinit.target

[Service]
Type=oneshot
StandardInput=tty
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start

[Install]
WantedBy=multi-user.target

And here is the command to disable the TTY1 systemd service:

sudo systemctl disable [email protected]

Now, the program appears interactively on TTY1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .