[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to write a proper fork hook code?



On Sun, 2015-03-01 at 22:06 +0100, Samuel Thibault wrote:
> Hello,
> 

> > #ifdef FCNTL_CALLS
> >       cmd = F_GETLK64;
> >       err = fcntl (fd1, cmd, &lock);
> >       if (err)
> > 	error (1, err, "fcntl child");
> >       printf ("Child lock status: '%s'\n", fcntl2str (lock.l_type));
> > #endif
> > 
> > #ifdef FCNTL_CALLS
> >       cmd = F_GETLK64;
> >       err = fcntl (fd1, cmd, &lock);
> >       if (err)
> > 	error (1, err, "fcntl parent");
> >       printf ("Parent lock status: '%s'\n", fcntl2str (lock.l_type));
> > #endif
> 
> Err, but I believe there is a misunderstanding here: F_GETLK does not
> return whether the caller has a lock on the file, but whether there is
> an existing lock that would prevent from acquiring one.

There is no misunderstanding at all (don't bother too much about this, I
could not use file_lock_stat in the FCNTL version) The problem is that
the fork call does not trigger the hook code in the RPC version.


Reply to: