You are not logged in.
I'm writing a daemon program that uses a PID file to detect if there is an instance running or not. This is how I am doing it.
int pid_file;
if ((pid_file = open("var/run/simpfand.pid", O_CREAT | O_EXCL)) == -1) {
printf("simpfand: another instance running! "
"Do not manually run.\n");
return 1;
}
...
close(pid_file);
It works fine, but if I wanted to restart the daemon, the PID file is still there and I have to manually delete it. I thought close would delete the file, but it doesn't. How do I get rid of this PID fiile?
Last edited by Hspasta (2012-09-29 06:21:45)
Offline
Offline
I guess I'm not really writing a daemon. I'm letting systemd do the running for me. I don't plan on calling fork() in my program.
Offline
Oh in such case, pidfile is not needed. You have this logic in systemd plus other lots of features
Offline
Oh. I think I was going about a problem wrong.
Thanks for the help.
Offline