dpkg (1.18.25) stretch; urgency=medium
[dpkg] / doc / frontend.txt
CommitLineData
1479465f
GJ
1Frontend Interfaces
2===================
3
4This file will try to document some of the interfaces that dpkg makes
5available to frontends or that expects them to use, which are currently
6not covered by any other type of documentation.
7
8
9Database Locking
10----------------
11
12Any frontend needing to make sure no write operation is currently happening,
13should lock the dpkg database by locking the file «<admindir>/lock» using
14file record locks (i.e. fcntl(2) advisory locking). The whole file should
15be locked, as that's the most portable way to perform this operation; this
16can be achieved by using start=0, len=0 and whence=SEEK_SET.
17
18Take into account there will be a race condition between the frontend
19unlocking the database and the invoked dpkg locking it again, in which
20another process could lock it.
21
22In the future this functionality will be available through a shared libdpkg
23library, and all frontends will be expected to switch to that instead,
24because this will fix the aforementioned race condition.