I am on a project for which I have to spawn many different processes, all in different executables, and there will be some shared memory segments and some semaphores to synchronize them. I use an "initializer" process to open some POSIX semaphores and allocate some shared memory segments.
I can not decide which is the best practice; to initialize the semaphores and load them to shared memory so everyone that acceses the memory can access them too or to pass them as command line arguments during exec?
I do not find any option better than the other, except from that the first might be redundant because the semaphores will probably never change (ID's their values will certainly change a lot) and accessing them without needing them (for some processes) is also not useful, but I have seen it happen, probably for a reason.
So I will need some reasoning for each as well.