FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 11-04-2008, 09:45 AM
Jules Colding
 
Default Has fcntl(2) left the building?

Hi,

I have a simple daemon which locks a file descriptor using fcntl(2) to
ensure that it is alone in the air. Specifically it does:


static int
lock_fd(const int fd)
{
struct flock lock = {
.l_type = F_WRLCK,
.l_start = 0,
.l_whence = SEEK_SET,
.l_len = 0,
};

if (-1 == fd)
return -1;

return fcntl(fd, F_SETLK, &lock);
}

The file descriptor "fd" has been successfully opened with:

g_open(file_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);


The problem is that it returns -1 and sets errno to EDEADLK. That
shouldn't be possible as far as I know. EDEADLK should only be set if
cmd was F_SETLKW but I'm using F_SETLK. Obviously my daemon fails to
lock the file.

I would very grateful if someone could tell me how this could happen
and how to avoid it.


The complete source is here:

http://trac.42tools.net/evolution-brutus/browser/trunk/session/
main.c


Best regards and thanks a lot in advance,
jules


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 01:31 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org