Another option would be to ditch fopen(which opens a file with FILE_SHARE_WRITE | FILE_SHARE_WRITE) and use CreateFile(https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx ) without FILE_SHARE_WRITE and from python check if we can write to it (since only the owner can write to it).
De la: Guru Shetty [mailto:g...@ovn.org] Trimis: Friday, July 15, 2016 5:49 AM Către: Alin Serdean <aserd...@cloudbasesolutions.com<mailto:aserd...@cloudbasesolutions.com>> Cc: Paul Boca <pb...@cloudbasesolutions.com<mailto:pb...@cloudbasesolutions.com>>; dev@openvswitch.org<mailto:dev@openvswitch.org> Subiect: Re: [ovs-dev] [PATCH V7] windows: Added lockf function and lock PID file What I was trying to say was, we open the file in write mode. It wouldn't have been successful if someone else had taken a lock (exclusive or shared). Am I correct? If so, why take exclusive lock again to write? Just write the pid and then take shared lock. Would that cause problems? (I must be missing some subtlety here.) [Alin Gabriel Serdean: ] If we just open the file in write mode and write the pid and then take the shared lock, someone else could write in the file between the moment we opened it and gained the shared lock. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev