What library to link for replacing lockf by _locking?

James Wong (Infrasys) james_wong@infrasys.com.hk
Fri Apr 21 05:09:00 GMT 2006


I followed an idea from the previous mailing list 
(http://www.cygwin.com/ml/cygwin-talk/2004-q4/msg00136.html) on emulating 
lockf by _locking provided by Windows standard runtime library.  However, 
the binary executable crashes everytime it runs.  I did the following and 
don't know if it has conflicts with cygwin.  Anyone has successfully ported 
lockf before ? Any sample code for reference ?

In the source code ......

#define LK_UNLCK _LK_UNLCK
#define LK_LOCK  _LK_LOCK
#define LK_NBLCK _LK_NBLCK
#define LK_RLCK  _LK_RLCK
#define LK_NBRLCK _LK_NBRLCK

#define lockf _locking              // _locking emulating lockf

#define F_ULOCK _LK_UNLCK /* Unlock locked sections. */
#define F_LOCK  _LK_LOCK  /* Lock a section for exclusive use. */
#define F_TLOCK _LK_NBLCK /* Test and lock a section for exclusive use */
#define F_TEST  _LK_RLCK  /* Test section for locks by other processes. */

When compile .... gcc xxx.c -o xxx -lcrtdll -L/usr/lib/mingw ... but xxx 
crashes

If I emulates lockf by dummy function simply just return 1, the binary 
executable will not crash but it simply cannot lock file. Is it the right 
direction to emulate lockf or any other alternative solution ?  Thks ~

James


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list