Version: (using KDE KDE 3.2.2) Installed from: RedHat RPMs OS: Linux In Red Hat (and probably some other distros as well), applications are not allowed to write to /var/lock directly. Instead they are supposed to use the lockdev library (which implements locking by calling a setgid helper binary). The configure script for kandy should check for the presence of the ttylock.h (or lockdev.h if a lower-level access is desired) and use lockdev for locking.
See also https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=84143
I don't have a distribution using lockdev here, so if you would like to see support for this the best way would be to provide a patch.
Similar problems arise on Sun's Solaris OS, since /var/lock doesn't exist at all. This problem is solved by providing a new element in the Kandy configuration dialog, category "Serial Device". There, you can now enter a directory where Kandy should place its LOCK file. If you enter /tmp there, it works on my Sun, and it's likely to work also for Red Hat. However, it's not very nice that Kandy doesn't issue any warning or so if the modem connection can not be established. The user is left alone here without any helpful notifications...
Placing the locks in /tmp defeats the purpose of locking since other applications would not look for them in there. On Red Hat and other distors that use lockdev, this is the preferred way of locking and it would be nice if it was supported.
Gonna address this (see also https://bugzilla.redhat.com/beta/show_bug.cgi?id=84143).
CVS commit by mornfall: Make kandy use lockdev instead of by-hand locking code, if available. BUGS:80228 M +12 -15 configure.in.in 1.3 M +1 -1 src/Makefile.am 1.13 M +18 -4 src/modem.cpp 1.10 --- kdepim/kandy/src/Makefile.am #1.12:1.13 @@ -4,5 +4,5 @@ kandy_LDFLAGS = $(KDE_RPATH) $(all_libraries) -kandy_LDADD = $(LIB_KFILE) -lkabc $(top_builddir)/libkdepim/libkdepim.la +kandy_LDADD = $(KANDY_LIBLOCKDEV) $(LIB_KFILE) -lkabc $(top_builddir)/libkdepim/libkdepim.la kandy_SOURCES = main.cpp kandy.cpp \ cmdpropertiesdialog_base.ui cmdpropertiesdialog.cpp \ --- kdepim/kandy/src/modem.cpp #1.9:1.10 @@ -265,7 +265,20 @@ void Modem::flush() } +#ifdef HAVE_LOCKDEV +#include <lockdev.h> +#endif bool Modem::lockDevice() { + if ( is_locked ) + return true; + +#ifdef HAVE_LOCKDEV + is_locked = !dev_lock( (*prefs).serialDevice().local8Bit() ); + if (!is_locked) + emit errorMessage( i18n( "Unable to lock device '%1'." ).arg( + (*prefs).serialDevice() )); + return is_locked; +#else ssize_t count; pid_t pid; @@ -275,8 +288,4 @@ bool Modem::lockDevice() QString fileName, content; - - if ( is_locked ) - return true; - pathList = QStringList::split( "/", (*prefs).serialDevice() ); fileName = (*prefs).lockDirectory() + "/LCK.." + pathList.last(); @@ -338,4 +347,5 @@ bool Modem::lockDevice() return true; +#endif } @@ -343,4 +353,7 @@ bool Modem::lockDevice() void Modem::unlockDevice() { +#ifdef HAVE_LOCKDEV + dev_unlock( (*prefs).serialDevice().local8Bit(), getpid() ); +#else if ( is_locked ) { QStringList pathList = QStringList::split( "/", (*prefs).serialDevice() ); @@ -349,4 +362,5 @@ void Modem::unlockDevice() is_locked = false; } +#endif }