LYX_CHECK_DEF(PATH_MAX, limits.h, [int n = PATH_MAX;])
-AC_CHECK_FUNCS(chmod close _close fork getpid _getpid lstat mkfifo open _open pclose _pclose popen _popen readlink putenv setenv strerror unsetenv)
+AC_CHECK_FUNCS(chmod close _close fork getpid _getpid lockf lstat mkfifo open _open pclose _pclose popen _popen readlink putenv setenv strerror unsetenv)
# Check the form of mkdir()
AC_FUNC_MKDIR
AC_FUNC_SELECT_ARGTYPES
set(Function_Defines)
foreach(_f alloca __argz_count __argz_next __argz_stringify
chmod close _close dcgettext fcntl fork __fsetlocking
- getcwd getegid getgid getpid _getpid gettext getuid lstat mempcpy mkdir _mkdir
+ getcwd getegid getgid getpid _getpid gettext getuid lstat lockf mempcpy mkdir _mkdir
mkfifo open _open pclose _pclose popen _popen putenv readlink
setenv setlocale strcasecmp stpcpy strdup strerror strtoul tsearch unsetenv wcslen)
string(TOUPPER ${_f} _UF)
prependEnvPath("PATH", replaceEnvironmentPath(lyxrc.path_prefix));
// Check that user LyX directory is ok.
- if (queryUserLyXDir(package().explicit_user_support()))
- reconfigureUserLyXDir();
+ {
+ string const lock_file = package().user_support().absFileName() + ".lyx_configure_lock";
+ int fd = fileLock(lock_file.c_str());
+
+ if (queryUserLyXDir(package().explicit_user_support())) {
+ reconfigureUserLyXDir();
+ }
+ fileUnlock(fd, lock_file.c_str());
+ }
if (!use_gui) {
// No need for a splash when there is no GUI
return true;
}
+int fileLock(const char * lock_file)
+{
+ int fd = -1;
+#if defined(HAVE_LOCKF)
+ fd = open(lock_file, O_CREAT|O_APPEND|O_SYNC|O_RDWR, 0666);
+ if (lockf(fd, F_LOCK, 0) != 0) {
+ close(fd);
+ return(-1);
+ }
+#endif
+ return(fd);
+}
+
+void fileUnlock(int fd, const char * lock_file)
+{
+#if defined(HAVE_LOCKF)
+ if ( fd >= 0) {
+ (void) lockf(fd, F_ULOCK, 0);
+ close(fd);
+ }
+#endif
+}
} //namespace support
} // namespace lyx
cmd_ret const runCommand(std::string const & cmd);
+int fileLock(const char * lock_file);
+void fileUnlock(int fd, const char * lock_file);
} // namespace support
} // namespace lyx