On Wed, Dec 21, 2005 at 06:41:40PM +0300, Michael Bushkov wrote: +> Hi! +> 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: +> http://rsu.ru/~bushman/libpidfile.patch +> +> 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. Thanks for the patch. Some comments: - There is a missing close(fd) is case of flock() == 0. - We can avoid reading when pidptr is NULL, right? Now it reads the file always, which is not always needed. I'm not going to commit the patch yet, I'll keep it in mind and commit when we can find a use for it. -- Pawel Jakub Dawidek http://www.wheel.pl pjd_at_FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am!
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:50 UTC