Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 06-11-2018, 11:30 PM   #1
Registered: Jul 2007
Posts: 189

Rep: Reputation: Disabled
-current: issues with installpkg and file locking

i'm testing -current from June 9 and for some reasons a manually created package won't install because installpkg seem to hang when executing the install script.

After doing some research i figured out that there was a lock file remaining which was still in use and installpkg could not get a lock for /run/lock/pkgtools/ installpkg will wait forever because there is no error handling if that happens.

OK, maybe a rare problem since normally the lock files will get unlocked, but shouldn't installpkg handle those issues better? Maybe using flock -w 30 9 || exit 11? In that case flock would fail after 30 seconds. installpkg would still not exit with an error because the sub-shell does not check if an error occurred.

--- /sbin/installpkg.orig	2018-05-31 21:37:47.000000000 +0200
+++ /sbin/installpkg	2018-06-12 06:10:16.780000000 +0200
@@ -647,13 +647,13 @@
       # rather than spawning subshells which is slow on ARM.  This will also speed up
       # install script processing on any platform.
       if [ -x /bin/bash ]; then
-        ( flock 9 || exit 11
+        ( flock -w 30 9 || exit 11
           cd $ROOT/ ; sed -e's?^( cd \([^;]*\);\(.*\) )$?pushd \1 \&\> /dev/null ; \2 ; popd \&\> /dev/null?g ' $INSTDIR/ | /bin/bash
-        ) 9> $INSTLOCKDIR/
+        ) 9> $INSTLOCKDIR/ || echo "Unable to create lock file $INSTLOCKDIR/"; exit 11
-        ( flock 9 || exit 11
+        ( flock -w 30 9 || exit 11
           cd $ROOT/ ; sh $INSTDIR/
-        ) 9> $INSTLOCKDIR/
+        ) 9> $INSTLOCKDIR/ || echo "Unable to create lock file $INSTLOCKDIR/"; exit 11
Or make sure the lock files get unlocked after was executed?
Old 06-11-2018, 11:48 PM   #2
Slackware Maintainer
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 1,727

Rep: Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419Reputation: 5419
The locks are released automatically when the file descriptor for the lock is closed. There's no need to close (or unlock) them manually, or to remove the lock files.

I've done a lot of testing with this here and have not run into this situation. I'd guess that somehow you had a process still running (maybe backgrounded?) that was holding onto the lock, but I'm not sure how that would occur. Maybe ^C at just the right time while installpkg is running?

Using -w 30 is a bad idea because rather than hanging if the lock is never released, the install script would be silently skipped. There's really no solution for this scenario that wouldn't either lead to install bugs or would bypass the whole reason for having locks in the first place.

I'll be interested to see if there are any other similar bug reports.
1 members found this post helpful.
Old 06-30-2018, 09:43 PM   #3
Registered: Jan 2014
Posts: 150

Rep: Reputation: 112Reputation: 112
Originally Posted by volkerdi View Post
I've done a lot of testing with this [lockfiles] ...
Pat, have you tried a scenario like this:

shell_1 $ installpkg *txz

shell_2 $ ROOT=/mnt installpkg *txz

I haven't tested it; I expect that it will work, but with unnecessary
waits due to shared lock files. Shouldn't the lock file path be $ROOT
aware? Something like:
if [ ! -d $INSTLOCKDIR ]; then
  mkdir -p $INSTLOCKDIR
Of course it would need to be moved to after options parsing then.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
installpkg to new root, but touched current files baldzhang Slackware 8 08-16-2017 08:27 AM
[SOLVED] Slackware Current - kernel_headers -- installpkg or upgradepkg kjhambrick Slackware 4 03-06-2016 06:15 PM
Slackware current installpkg line 59 rev command not found disturbed1 Slackware 4 02-28-2011 04:03 PM
File locking issues with clustering, GFS, and NFS tmccord1 Linux - Server 3 05-05-2010 03:38 PM
[SOLVED] Installind Slamd64-current. "cannot execute binary file" message about installpkg BrutalMusic Slackware - Installation 1 05-11-2006 09:35 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration