I'm compiling dillo on Cygwin, which lacks of flock/lockf, but has support for POSIX file lock (fcntl()). To enable the cookies support, I write a patch for it. In hope that it will be useful for other platform having similar situation. diff -Nurp dillo-0.6.6/src/cookies.c dillo-0.6.6-cygwin/src/cookies.c --- dillo-0.6.6/src/cookies.c 2002-05-28 04:47:50.000000000 +0800 +++ dillo-0.6.6-cygwin/src/cookies.c 2003-03-01 10:23:56.000000000 +0800 @@ -130,6 +130,9 @@ void a_Cookies_init() GList *domain_cookies; char *filename; char line[LINE_MAXLEN]; +#ifndef HAVE_LOCKF + struct flock lck; +#endif Cookie_control_init(); @@ -145,7 +148,16 @@ void a_Cookies_init() } /* Try to get a lock from the file descriptor */ +#ifdef HAVE_LOCKF disabled = (lockf(fileno(file_stream), F_TLOCK, 0) == -1); +#else /* POSIX lock */ + lck.l_start = 0; /* start at beginning of file */ + lck.l_len = 0; /* lock entire file */ + lck.l_type = F_WRLCK; + lck.l_whence = SEEK_SET; /* absolute offset */ + + disabled = (fcntl(fileno(file_stream), F_SETLK, &lck) == -1); +#endif if (disabled) { DEBUG_MSG(10, "The cookies file has a file lock:\n" " disabling cookies in this dillo!\n"); @@ -278,6 +290,9 @@ static gboolean Cookies_freeall_cb(gpoin void a_Cookies_freeall() { int fd; +#ifndef HAVE_LOCKF + struct flock lck; +#endif if (disabled) return; @@ -288,7 +303,16 @@ void a_Cookies_freeall() g_hash_table_foreach_remove(cookies, Cookies_freeall_cb, NULL); +#ifdef HAVE_LOCKF lockf(fd, F_ULOCK, 0); +#else /* POSIX file lock */ + lck.l_start = 0; /* start at beginning of file */ + lck.l_len = 0; /* lock entire file */ + lck.l_type = F_UNLCK; + lck.l_whence = SEEK_SET; /* absolute offset */ + + fcntl(fileno(file_stream), F_SETLKW, &lck); +#endif fclose(file_stream); } --------------------------------------------- »¶Ó¹âÁÙ http://www.cmmail.com