diff options
| author | shtrophic <christoph@liebender.dev> | 2024-11-19 21:40:18 +0100 |
|---|---|---|
| committer | shtrophic <christoph@liebender.dev> | 2024-11-19 21:40:18 +0100 |
| commit | 67431130162b1027cc3894f947be309b2daa3cd3 (patch) | |
| tree | 847930f363f0d6f13e688342dab8623de78db651 /httpd.c | |
| parent | 972783fcb2d7855847f0ea0832da2abc71aa6b30 (diff) | |
| parent | 3a9118524831d1f3a9168034c1655e515f162020 (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -774,6 +774,7 @@ void httpd(void) xs *sem_name = NULL; xs *shm_name = NULL; sem_t anon_job_sem; + xs *pidfile = xs_fmt("%s/server.pid", srv_basedir); address = xs_dict_get(srv_config, "address"); @@ -809,6 +810,17 @@ void httpd(void) srv_log(xs_fmt("httpd%s start %s %s", p_state->use_fcgi ? " (FastCGI)" : "", full_address, USER_AGENT)); + { + FILE *f; + + if ((f = fopen(pidfile, "w")) != NULL) { + fprintf(f, "%d\n", getpid()); + fclose(f); + } + else + srv_log(xs_fmt("Cannot create %s: %s", pidfile, strerror(errno))); + } + /* show the number of usable file descriptors */ struct rlimit r; getrlimit(RLIMIT_NOFILE, &r); @@ -894,4 +906,6 @@ void httpd(void) srv_log(xs_fmt("httpd%s stop %s (run time: %s)", p_state->use_fcgi ? " (FastCGI)" : "", full_address, uptime)); + + unlink(pidfile); } |