Skip to content

Commit d653ec4

Browse files
committed
Log pidfile creation and removal
The pidfile is also used as a lock file. Add logs to reveal incorrect creation or removal of the pidfile. When creating a pidfile we will see: INFO | Created pidfile "/tmp/socket_vmnet.pid" for process 37297 When removing we will see: INFO | Removed pidfile "/tmp/socket_vmnet.pid" for process 37297 Signed-off-by: Nir Soffer <nirsof@gmail.com>
1 parent daadaf3 commit d653ec4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ static void remove_pidfile(const char *pidfile)
358358
{
359359
if (unlink(pidfile) != 0) {
360360
ERRORF("Failed to remove pidfile: \"%s\": %s", pidfile, strerror(errno));
361+
return;
361362
}
363+
INFOF("Removed pidfile \"%s\" for process %d", pidfile, getpid());
362364
}
363365

364366
static int create_pidfile(const char *pidfile)
@@ -385,6 +387,7 @@ static int create_pidfile(const char *pidfile)
385387
return -1;
386388
}
387389

390+
INFOF("Created pidfile \"%s\" for process %d", pidfile, getpid());
388391
return fd;
389392
}
390393

0 commit comments

Comments
 (0)