How do I make a unix executable (from the /target/debug/ dir) run in the background

Recently, I was developing an app in rust, and I realized that it would not continue to run after I closed the terminal. What is the best way to code a rust program so that when you take the unix executable from the /target/debug/ directory, you can execute it and close the terminal without the program terminating? Maybe I could somehow convert the rust application to a .app (an application file for macos)?

P.S. Can I achieve this without using terminal to run the excecutable with "./rustapplicationunixexecutable &". I do know that the & symbol will make the process run in the background, however I want users to simply be able to double click the executable (or .app file) and have it run.

You will have to catch and ignore the SIGHUP signal somehow.

On Linux there is the nohup Program with witch you can do what @alice suggested.
I used it to run processes in the background manually but I think it should be no problem to provide users with a script that runs nohup instead of directly running your binary

You can also run it like that:

./application &
disown %1
exit

do detatch it from the terminal and close the terminal. However, you will then not be able to see the output, if you don't redirect it to a file.

Hey why don't you try creating a persistent service using this guide from Apple?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.