Daemon programming: allocated memory vs. fork()
I experienced some problems while porting some programs from Solaris to Linux. They are all calling fork() after being started so they run in daemon mode. I also have a debug mode that just skip the daemonize function that I wrote. (this function actually just call the fork method and make the parent process to exit normally and the child process to continu the execution of the program).
My problem is that while it run in daemon mode, it exit after a while without any warning/error/log message/etc... so I really don't know what is happening. I tested for days in debug mode and it works just fine and could run for months without problem.
So, I guess that it's all coming from the dameonize function that is actually calling fork(). I have few question that may answer and solve my problem:
1- Normally on Solaris, fork() duplicate the overall memory space of a process, is it the same under Linux or should I make alll my dynamic memory allocation after the fork() call?
2-What is the difference with the other fork() function: vfork, and so on... ? Is one of them more appropriate for what I'm doing?
3-Any other thought/suggestions about this?
Thank you very much!
P.S.: this was actually a reply made into another thread, but like it is a completely different fork() issue than the previous thread, I just decided to create a new thread for it...