explicitely note & check whether a pidfile was written
This commit is contained in:
@@ -82,6 +82,7 @@ int foreground = FALSE;
|
||||
static int report_level = UNSET_INT;
|
||||
static int report_dest = UNSET_INT;
|
||||
char *pidfile = NULL;
|
||||
int pidfile_written = FALSE;
|
||||
char *displayname = NULL;
|
||||
char *default_shell = NULL;
|
||||
|
||||
@@ -144,6 +145,7 @@ int main(int argc, char **argv)
|
||||
if (pidf) {
|
||||
fprintf(pidf, "%d\n", (int) getpid());
|
||||
fclose(pidf);
|
||||
pidfile_written = TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "Error creating pidfile %s: %s\n",
|
||||
pidfile, strerror(errno));
|
||||
@@ -178,7 +180,7 @@ static void exit_program(int val)
|
||||
//printf("exit program\n");
|
||||
Quit = 1;
|
||||
sock_close(sock);
|
||||
if ((foreground != TRUE) && (pidfile != NULL))
|
||||
if ((foreground != TRUE) && (pidfile != NULL) && (pidfile_written == TRUE))
|
||||
unlink(pidfile);
|
||||
exit(val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user