1 /* Filename: dpkg_not_running
2 * Purpose: check whether Debian's package management (dpkg) is running
3 * Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
4 * Bug-Reports: see http://grml.org/bugs/
5 * License: This file is licensed under the GPL v2.
6 * Latest change: Mit Jun 28 18:13:43 CEST 2006 [mika]
7 *******************************************************************************/
8 // return 0 if it is not running; return 1 if it is running
15 int main(int argc, char *argv[])
17 struct flock fl = { F_WRLCK, SEEK_SET, 0, 0, 0 };
21 if ((fd = open("/var/lib/dpkg/lock", O_RDWR)) == -1) {
25 if (fcntl(fd, F_SETLK, &fl) == -1) {
26 exit(1); // it is running
29 exit(0); // it is not running
35 /* END OF FILE ****************************************************************/