Separating c code files per process

Linux-SWAT

Hardcore Member
Joined
Feb 13, 2010
Messages
8,274
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 ?
 

levi

Still fresh, damnit!
Joined
Oct 6, 2008
Messages
11,955
Location
Somewhere off the coast of the EU
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.
 

TeDaDeS

Very Active Member
Joined
Jan 15, 2004
Messages
895
Location
The Netherlands
Website
Visit site
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.
 
Top