diff options
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index aeb3f71e2f..70cccefe0c 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -38,6 +38,8 @@ import bb, bb.exceptions, bb.command | |||
38 | from bb import utils, data, parse, event, cache, providers, taskdata, runqueue | 38 | from bb import utils, data, parse, event, cache, providers, taskdata, runqueue |
39 | import Queue | 39 | import Queue |
40 | import signal | 40 | import signal |
41 | import subprocess | ||
42 | import errno | ||
41 | import prserv.serv | 43 | import prserv.serv |
42 | import pyinotify | 44 | import pyinotify |
43 | 45 | ||
@@ -1442,6 +1444,33 @@ class BBCooker: | |||
1442 | def post_serve(self): | 1444 | def post_serve(self): |
1443 | prserv.serv.auto_shutdown(self.data) | 1445 | prserv.serv.auto_shutdown(self.data) |
1444 | bb.event.fire(CookerExit(), self.event_data) | 1446 | bb.event.fire(CookerExit(), self.event_data) |
1447 | lockfile = self.lock.name | ||
1448 | self.lock.close() | ||
1449 | self.lock = None | ||
1450 | |||
1451 | while not self.lock: | ||
1452 | with bb.utils.timeout(3): | ||
1453 | self.lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=True) | ||
1454 | if not self.lock: | ||
1455 | # Some systems may not have lsof available | ||
1456 | procs = None | ||
1457 | try: | ||
1458 | procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) | ||
1459 | except OSError as e: | ||
1460 | if e.errno != errno.ENOENT: | ||
1461 | raise | ||
1462 | if procs is None: | ||
1463 | # Fall back to fuser if lsof is unavailable | ||
1464 | try: | ||
1465 | procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) | ||
1466 | except OSError as e: | ||
1467 | if e.errno != errno.ENOENT: | ||
1468 | raise | ||
1469 | |||
1470 | msg = "Delaying shutdown due to active processes which appear to be holding bitbake.lock" | ||
1471 | if procs: | ||
1472 | msg += ":\n%s" % str(procs) | ||
1473 | print(msg) | ||
1445 | 1474 | ||
1446 | def shutdown(self, force = False): | 1475 | def shutdown(self, force = False): |
1447 | if force: | 1476 | if force: |