mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Overwrite PID file if it exists
This commit is contained in:
parent
dd35f04ec8
commit
80633bac29
11
src/elogd.c
11
src/elogd.c
@ -29714,14 +29714,9 @@ void server_loop(void) {
|
|||||||
|
|
||||||
/* check if file exists */
|
/* check if file exists */
|
||||||
if (stat(pidfile, &finfo) >= 0) {
|
if (stat(pidfile, &finfo) >= 0) {
|
||||||
eprintf("File \"%s\" exists, using \"%s.%d\" instead.\n", pidfile, pidfile, elog_tcp_port);
|
/* if it exists remove it */
|
||||||
sprintf(pidfile + strlen(pidfile), ".%d", elog_tcp_port);
|
eprintf("File \"%s\" exists, overwriting it.\n", pidfile);
|
||||||
|
remove(pidfile);
|
||||||
/* check again for the new name */
|
|
||||||
if (stat(pidfile, &finfo) >= 0) {
|
|
||||||
/* never overwrite a file */
|
|
||||||
eprintf("Refuse to overwrite existing file \"%s\".\n", pidfile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = open(pidfile, O_CREAT | O_RDWR, 0644);
|
fd = open(pidfile, O_CREAT | O_RDWR, 0644);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user