Skip to content

Commit

Permalink
mx_flock: Add mx_funlock_nodelete
Browse files Browse the repository at this point in the history
Add function to release the lock without removing the logfile. This is
useful for forked children, which inherited the lock and just need to
give it up.
  • Loading branch information
donald committed Sep 17, 2021
1 parent 2601e06 commit 0be33f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mx_flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ int mx_funlock(struct mx_flock *lock)
return res;
}

/* as above, but don't delete lock file
*/
void mx_funlock_nodelete(struct mx_flock *lock) {
_flock_close(lock);
_flock_free(lock);
}

void mx_flock_free(struct mx_flock *lock)
{
_flock_free(lock);
Expand Down
1 change: 1 addition & 0 deletions mx_flock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct mx_flock {

struct mx_flock *mx_flock(int operation, char *fmt, ...);
int mx_funlock(struct mx_flock *lock);
void mx_funlock_nodelete(struct mx_flock *lock);
void mx_flock_free(struct mx_flock *lock);

#endif

0 comments on commit 0be33f7

Please sign in to comment.