Search code examples
c#.netbashgrpc

Avoid stopping background process in Bash


I have a gRPC server built on the legacy .NET gRPC library. The server starts and then waits for a readline on stdin. This works perfectly well when started directly, both on Windows and Linux.

However, when I start the process on Linux in the background (dotnet MyServer.dll &), Bash apparently thinks that the process is idle and stops it.

[1]+ Stopped dotnet MyServer.dll

How can I tell Bash to not stop the process, or even better, how do I modify my program to declare that it is not to be stopped.

Interestingly, when I do the same thing with a server implemented using ASP.NET Core, Bash does not stop it and lets it run.


Solution

  • The server starts and then waits for a readline on stdin.

    When a background process tries to read terminal input it'll be sent signal SIGTTIN which by default would stop the process.

    You can try like this:

    echo "the data required by the server program" | dotnet MyServer.dll &