If we fail to write the pid to the pid file, we should still close the
file before returning from write_pid_file(). The consequences of this
bug are trivial because kadmin is just going to exit regardless.
Reported by Will Fiveash <will.fiveash@oracle.com>.
{
FILE *file;
unsigned long pid;
+ int st1, st2;
file = fopen(pid_file, "w");
if (file == NULL)
return errno;
pid = (unsigned long) getpid();
- if (fprintf(file, "%ld\n", pid) < 0 || fclose(file) == EOF)
- return errno;
- return 0;
+ st1 = fprintf(file, "%ld\n", pid);
+ st2 = fclose(file);
+ return (st1 < 0 || st2 == EOF) ? errno : 0;
}
/* XXX yuck. the signal handlers need this */