Sat, 12 Nov 2022 17:00:16 +0100
add check if pidfile can be opened
src/server/daemon/webserver.c | file | annotate | diff | comparison | revisions |
--- a/src/server/daemon/webserver.c Sat Nov 12 16:52:32 2022 +0100 +++ b/src/server/daemon/webserver.c Sat Nov 12 17:00:16 2022 +0100 @@ -205,7 +205,11 @@ char *pid_file_path = NULL; asprintf(&pid_file_path, "%s/pid", cfg->tmp.ptr); - FILE *pidfile = fopen(pid_file_path, "w"); // TODO: check error + FILE *pidfile = fopen(pid_file_path, "w"); + if(!pidfile) { + log_ereport(LOG_FAILURE, "cannot open pid file %s: %s", pid_file_path, strerror(errno)); + return -1; + } pid_t pid = getpid(); fprintf(pidfile, "%d", pid); fclose(pidfile);