1 /* @(#) $Id: wait_op.c,v 1.5 2009/06/24 18:53:09 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
18 /* Creates global lock */
23 /* For same threads. */
29 fp = fopen(WAIT_FILE, "w");
33 fp = fopen(WAIT_FILE_PATH, "w");
46 /* Removes global lock */
57 unlink(WAIT_FILE_PATH);
64 /* Check for the wait file. If present, wait.
65 * Works as a simple inter process lock (only the main
66 * process is allowed to lock).
75 /* Wait until the lock is gone. */
76 verbose(WAITING_MSG, __local_name);
82 /* Sleep LOCK_LOOP seconds and check it lock is gone. */
87 verbose(WAITING_FREE, __local_name);
96 struct stat file_status;
99 /* If the wait file is not present, keep going.
103 if(stat(WAIT_FILE, &file_status) == -1)
108 if(stat(WAIT_FILE_PATH, &file_status) == -1)
113 /* Wait until the lock is gone. */
114 verbose(WAITING_MSG, __local_name);
119 if(stat(WAIT_FILE, &file_status) == -1)
124 if(stat(WAIT_FILE_PATH, &file_status) == -1)
128 /* Sleep LOCK_LOOP seconds and check it lock is gone. */
132 verbose(WAITING_FREE, __local_name);