question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked cheong00 edited

How to close .net core console application on linux machine?

Hi,
How to close .Net core console application in linux machine?
Becasue .Net core console application is running on terminal window on linux.
If user want to close application,how to allow to user to close it? my application is long running process...
If i close the terminal window,console also will close?

dotnet-csharpdotnet-runtimedotnet-runtime-frameworkdotnet-runtime-coredotnet-console
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cheong00 avatar image
0 Votes"
cheong00 answered cheong00 edited

Adding " &" when running command in *nix will put it into background.

You can then just ignore it, [or use "wait" command to wait until the background process you just run ends.][1]

Although I'll probably wrap it as [systemd service][2].

In both way, you can let users kill them by adding the followings to your /etc/sudoers file.

<username> ALL = /usr/bin/pkill <yourprocessname>
<username> ALL = /usr/bin/pkill stop <yourservicename>, /usr/bin/pkill start <yourservicename>

where <username>,<yourprocessname> and <yourservicename> are all placeholders which you should change accordingly.
[1]: https://unix.stackexchange.com/questions/76717/launch-a-background-process-and-check-when-it-ends/76720
[2]: https://www.freedesktop.org/software/systemd/man/systemd.service.html

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.