Skip to content
Snippets Groups Projects
Commit a20fe795 authored by Moe Jette's avatar Moe Jette
Browse files

Close pidfile if error on write, previously would leave orphan

open file descriptor.
parent 3f86d924
No related branches found
No related tags found
No related merge requests found
...@@ -176,22 +176,18 @@ create_pidfile(const char *pidfile) ...@@ -176,22 +176,18 @@ create_pidfile(const char *pidfile)
if (fd_get_write_lock(fileno(fp)) < 0) { if (fd_get_write_lock(fileno(fp)) < 0) {
error ("Unable to lock pidfile `%s': %m", pidfile); error ("Unable to lock pidfile `%s': %m", pidfile);
fclose(fp);
goto error; goto error;
} }
if (fprintf(fp, "%lu\n", (unsigned long) getpid()) == EOF) { if (fprintf(fp, "%lu\n", (unsigned long) getpid()) == EOF) {
error("Unable to write to pidfile `%s': %m", pidfile); error("Unable to write to pidfile `%s': %m", pidfile);
fclose(fp);
goto error; goto error;
} }
fflush(fp); fflush(fp);
/*
* if (fclose(fp) == EOF) {
* error("Unable to close pidfile `%s': %m", pidfile);
* goto error;
*}
*/
return (fileno(fp)); return (fileno(fp));
error: error:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment