+static int one_and_only(void)
+{
+ char string[100];
+
+ lock_file = open(lock_filename, O_RDWR | O_CREAT, 0x640);
+
+ /* see if we can open */
+ if (lock_file < 0)
+ return -EINVAL;
+
+ /* see if we can lock */
+ if (lockf(lock_file, F_TLOCK, 0) < 0) {
+ close(lock_file);
+ unlink(lock_filename);
+ return -EINVAL;
+ }
+
+ snprintf(string, sizeof(string), "%d\n", getpid());
+ write(lock_file, string, strlen(string));
+
+ return 0;
+}
+