Separating c code files per process


Linux-SWAT

Forum Addict!
Joined
Feb 13, 2010
Messages
9,171
Hi,

I would like to know how to properly organize c files, I'll use fork() and I'd like processus to have their own .c/.h files.
Better to have the fork() in the main parent or in the separate files ?
 
It's up to you isn't it? You could import the daughter files in the main c file and call their functions from a fork, or you could define those functions locally. It doesn't matter once it's been through the preprocessor.
 
If you use fork it implies the child process is somewhat completely separate from the (main) parent process, else you would have used a thread.
In that case I assume it is more logical to put the fork into the main function of the parent, as the child process itself does not 'care' about what the parent process do as the process itself does not use fork (or it has to have child processes to).

Also if there is a situation where you would want to use each .c file separately for some reason; you would probably not use the fork function in that file, right?

What ever you choose I would at least keep it consistent.
 
Back
Top