From e765d3c3052b65fec071cf6f0625f43b9b68965c Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 23 May 2014 14:06:41 +0800 Subject: [PATCH] don't unlock pidfile after write pid --- skynet-src/skynet_daemon.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/skynet-src/skynet_daemon.c b/skynet-src/skynet_daemon.c index 6a557b76..d77a67a2 100644 --- a/skynet-src/skynet_daemon.c +++ b/skynet-src/skynet_daemon.c @@ -60,19 +60,13 @@ write_pid(const char *pidfile) { } fflush(f); - if (flock(fd, LOCK_UN) == -1) { - fprintf(stderr, "Can't unlock pidfile %s.\n", pidfile); - close(fd); - return 0; - } - close(fd); - return pid; } int daemon_init(const char *pidfile) { int pid = check_pid(pidfile); + if (pid) { fprintf(stderr, "Skynet is already running, pid = %d.\n", pid); return 1; @@ -93,5 +87,5 @@ daemon_init(const char *pidfile) { int daemon_exit(const char *pidfile) { - return unlink (pidfile); + return unlink(pidfile); }