• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

flock in Solaris

 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic