mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
don't unlock pidfile after write pid
This commit is contained in:
@@ -60,19 +60,13 @@ write_pid(const char *pidfile) {
|
|||||||
}
|
}
|
||||||
fflush(f);
|
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;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
daemon_init(const char *pidfile) {
|
daemon_init(const char *pidfile) {
|
||||||
int pid = check_pid(pidfile);
|
int pid = check_pid(pidfile);
|
||||||
|
|
||||||
if (pid) {
|
if (pid) {
|
||||||
fprintf(stderr, "Skynet is already running, pid = %d.\n", pid);
|
fprintf(stderr, "Skynet is already running, pid = %d.\n", pid);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -93,5 +87,5 @@ daemon_init(const char *pidfile) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
daemon_exit(const char *pidfile) {
|
daemon_exit(const char *pidfile) {
|
||||||
return unlink (pidfile);
|
return unlink(pidfile);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user