0

I'm using Mono on a Linux system to launch a process. Occassionaly the parent process dies an untimely death, and takes the child process with it, but I need to keep the child process going.
In testing, every variation of System.Diagnostics.Process.Start() I've tested will cause it's child process to die when I kill the parent process. is there some setting I'm missing, or another way to accomplish this? As a test, this:

System.Diagnostics.Process.Start(new ProcessStartInfo("journalctl", "-f") {UseShellExecute = true});


this:

System.Diagnostics.Process.Start(new ProcessStartInfo("journalctl", "-f") {UseShellExecute = false});

and this:

System.Diagnostics.Process.Start("journalctl", "-f");

will launch 'journalctl' ('ps -aef' indicates correct parent-child IDs) and when I kill the parent process, 'journalctl' also dies.
Should I launch a script that has uses nohup and disown for the the child process?

Gio
  • 4,099
  • 3
  • 30
  • 32

1 Answers1

0

Complete disassociation of a child process from the parent requires a number of system calls to be made by the child process; these may be easier to do via a shell wrapper if MONO lacks access to the appropriate system calls (fork to first create the child process and then setsid to escape the parent process group, dealing with the standard input and standard output file handles, possibly a chdir to /, and anything else I've forgotten). Your MONO calls look more akin to the system(3) system call, which also would require using a wrapper program for the setsid and such.

thrig
  • 676
  • 4
  • 11