I have a .NET 6 application that runs as a systemd service on Linux. This application executes another program with a command like the following:
var process = Process.Start(new ProcessStartInfo
{
FileName = "foo",
Arguments = "bar",
});
This process should continue to run even when this application that started it is terminated. Which as far as I understand is what Process.Start
should do. But in my case I'm observing now that the spawned process is getting terminated at the same time as the original process when I stop the original process via systemctl stop
.
Both get stopped within the same millisecond, I added a handler for the AppDomain.CurrentDomain.ProcessExit
event to both that gets triggered, which does indicate to me that they both get a SIGTERM from systemd.
Now, I assume that systemd does something else here to clean up the service as usually my spawned process should live on when the original dies. How can I start a process in a way that won't be killed by systemd when the parent is stopped?