I have basically a console C++ app for Linux CentOS9. I am going to run it as a service using systemctl start/stop
.
Currently the app exits if user press Enter in the console but this wont be possible in service mode as the user wont see the app console after logging in.
What can be done so I the app can detect it is being stopped/terminated so it can cleanup resources (closing files)?