- Posted In
- Red Hat Enterprise Linux
Would really appreciate if someone could help me out with a problem I'm having creating a daemon process on RHEL 8.3.
Here's a simple piece of C code to show my issue (apologies for the formatting) :
pid = fork();
if (pid == 0)
It just forks a process that sleeps for 30 seconds - I want this to detach and run in its own process group.
When I run on RHEL 7 I get the following process entry :
root 16918 1 0 19:53 ? 00:00:00 ./myprogram
As you can cee the PPID is correctly set to 1, which is what I want.
If I compile and run the exact same code on RHEL 8.3 I get the following process entry:
root 6432 4845 0 20:08 ? 00:00:00 ./myprogram
As you can see the PPID is not set to 1, but is still part of the session where the program was run from. This means that when the parent exits, e.g. I log off, the daemon process will be killed.
** Q : does anyone know what changed with 8.3 and have any ideas of the code change I need to make to accommodate? **
Many thanks in advance for any advice.