1 /* @(#) $Id: ./src/shared/wait_op.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
19 /* Creates global lock */
24 /* For same threads. */
30 fp = fopen(WAIT_FILE, "w");
34 fp = fopen(WAIT_FILE_PATH, "w");
47 /* Removes global lock */
58 unlink(WAIT_FILE_PATH);
65 /* Check for the wait file. If present, wait.
66 * Works as a simple inter process lock (only the main
67 * process is allowed to lock).
76 /* Wait until the lock is gone. */
77 verbose(WAITING_MSG, __local_name);
83 /* Sleep LOCK_LOOP seconds and check it lock is gone. */
88 verbose(WAITING_FREE, __local_name);
97 struct stat file_status;
100 /* If the wait file is not present, keep going.
104 if(stat(WAIT_FILE, &file_status) == -1)
109 if(stat(WAIT_FILE_PATH, &file_status) == -1)
114 /* Wait until the lock is gone. */
115 verbose(WAITING_MSG, __local_name);
120 if(stat(WAIT_FILE, &file_status) == -1)
125 if(stat(WAIT_FILE_PATH, &file_status) == -1)
129 /* Sleep LOCK_LOOP seconds and check it lock is gone. */
133 verbose(WAITING_FREE, __local_name);