[PATCH] pidfile_check() possible function

Michael Bushkov bushman at rsu.ru
Wed Dec 21 07:36:35 PST 2005

I've made a sample implementation of pidfile_check() function based on 
pkill's takepid() function. It's interface is like this:
int pidfile_check(const char *path, int pidfilelock, pid_t *pidptr);

The patch is here:

pidfile_check returns 0 if the pidfile owner seems to be active and (-1) 
otherwise (in case of failure errno would also be set).

The path argument is the path of the pidfile. If pidfilelock is not 0, 
the function will attempt to lock the file to check if the pidfile owner 
is currently running. If pidptr is not NULL and pidfile owner seems to 
be active, it's pid will be placed in pidptr.

Looking forward for your comments and suggestions!
Michael Bushkov

More information about the freebsd-current mailing list