LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


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

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


Hi...
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/doinst.sh.lock. 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.

Code:
--- /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/doinst.sh | /bin/bash
-        ) 9> $INSTLOCKDIR/doinst.sh.lock
+        ) 9> $INSTLOCKDIR/doinst.sh.lock || echo "Unable to create lock file $INSTLOCKDIR/doinst.sh.lock"; exit 11
       else
-        ( flock 9 || exit 11
+        ( flock -w 30 9 || exit 11
           cd $ROOT/ ; sh $INSTDIR/doinst.sh
-        ) 9> $INSTLOCKDIR/doinst.sh.lock
+        ) 9> $INSTLOCKDIR/doinst.sh.lock || echo "Unable to create lock file $INSTLOCKDIR/doinst.sh.lock"; exit 11
       fi
     fi
   fi
Or make sure the lock files get unlocked after doinst.sh was executed?
 
Old 06-11-2018, 11:48 PM   #2
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 1,493

Rep: Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336Reputation: 4336
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.
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:05 AM.

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