• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

flock in Solaris

 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic