1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
14 static int __wait_lock = 0;
17 /* Create global lock */
22 /* For same threads */
26 fp = fopen(WAIT_FILE, "w");
28 fp = fopen(WAIT_FILE_PATH, "w");
39 /* Remove global lock */
47 unlink(WAIT_FILE_PATH);
52 /* Check for the wait file. If present, wait.
53 * Works as a simple inter process lock (only the main
54 * process is allowed to lock).
63 /* Wait until the lock is gone */
64 verbose(WAITING_MSG, __local_name);
70 /* Sleep LOCK_LOOP seconds and check if lock is gone */
74 verbose(WAITING_FREE, __local_name);
83 struct stat file_status;
85 /* If the wait file is not present, keep going */
87 if (stat(WAIT_FILE, &file_status) == -1) {
91 if (stat(WAIT_FILE_PATH, &file_status) == -1) {
96 /* Wait until the lock is gone */
97 verbose(WAITING_MSG, __local_name);
100 if (stat(WAIT_FILE, &file_status) == -1) {
104 if (stat(WAIT_FILE_PATH, &file_status) == -1) {
109 /* Sleep LOCK_LOOP seconds and check if lock is gone */
113 verbose(WAITING_FREE, __local_name);