view src/mylocking.c @ 0:21ce01de8109

Initial revision
author mmj
date Thu, 22 Apr 2004 04:02:09 +1000
parents
children a642323b9d02
line wrap: on
line source

/* Copyright (C) 2002, 2003 Mads Martin Joergensen <mmj at mmj.dk>
 *
 * $Id$
 *
 * This file is redistributable under version 2 of the GNU General
 * Public License as described at http://www.gnu.org/licenses/gpl.txt
 */

#include <unistd.h>
#include <fcntl.h>
#include "mylocking.h"

int myexcllock(int fd)
{
	int mylock;
	struct flock locktype;

	locktype.l_type = F_WRLCK;
	locktype.l_whence = SEEK_SET;
	locktype.l_start = 0;
	locktype.l_len = 0;
	mylock = fcntl(fd, F_SETLKW, &locktype);

	return mylock;
}

int myunlock(int fd)
{
	int myunlock;
	struct flock locktype;

	locktype.l_type = F_UNLCK;
	myunlock = fcntl(fd, F_SETLKW, &locktype);

	return myunlock;
}