return fcntl(fd, F_SETLK, &l) == -1 ? errno : 0;
}
-/* Remove the lockfile with 'name'. If the 'fd' argument is not -1, it
- * will be closed. */
+/* Remove the lockfile with 'name'. */
int
-remove_lockfile(int fd, const char *name)
+remove_lockfile(const char *name)
{
char buffer[BUFSIZ];
ssize_t n;
pid_t pid;
-
- if (fd != -1) {
- close(fd);
- }
+ int fd;
/* Remove existing lockfile. */
fd = open(name, O_RDWR);
int fd;
/* Remove an existing lockfile if it was created by us. */
- int retval = remove_lockfile(-1, name);
+ int retval = remove_lockfile(name);
if (!retval) {
return retval;
}
#define LOCKFILE_H 1
int create_lockfile(const char *name);
-int remove_lockfile(int fd, const char *name);
+int remove_lockfile(const char *name);
#endif /* lockfile.h */