In Linux systems there is a flock command that is used to create a lock file so that processes can synchronize execution of some protected resource. I understand that Solaris systems don't support this. Is there some other equivalent command that functions similar to flock?
My shell programming is very rusty...coming back slowly.
I am developing a prototype using cygwin with Windows XP.
I have a master shell which starts 5 processes in the background. I need someway to have the processes communicate with each other, i.e. some sort of shared memory or lock file (semaphore).
I export environmental variables and the sub processes can read them but when they change them the other processes don't get the change as they have their own address space (and are not part of the parent-child relationship.)
Any help is greatly appreciated. [ July 23, 2008: Message edited by: James Clark ]
Are you sure you want to do this? file locking is actually a very complex topic, espcially if any of the files can be on network structures such as NFS or SMB. Its really hard to do it reliably and transportably.
I'd just write what you want in Perl, rather than a shell, and use its facilities. Let someone else struggle with the implementation details.
Joined: Apr 16, 2008
Thank you. We are thinking about Perl threads. In order to code Perl threads however, the compiler must be configured for this and we don't really want to rebuild the compiler for our new component. There are significant programs in Perl that are working fine now and we don't want to disrupt this.
For the cygwin prototype, we have developed a reliable communication system using the shared filesystem. And are programming to explicitly avoid potential issues with resource contention and deadlocks.
It is suprising that Solaris does not have a flock equivalent, however.