diff options
| author | Giacomo Tesio <giacomo@tesio.it> | 2024-12-05 22:53:40 +0100 |
|---|---|---|
| committer | Giacomo Tesio <giacomo@tesio.it> | 2024-12-05 22:53:40 +0100 |
| commit | bd74ffda5b25cc07e8d559815e027c8dab3b9d73 (patch) | |
| tree | 00725a5d5f53ed421b923de6fc1892c58815cc16 /httpd.c | |
| parent | b6107c8777a6f98dd89218ede1020a27ee83be70 (diff) | |
| parent | 221eeabf0c00f076ee8ae670811aabbc5b11a826 (diff) | |
Merge branch 'master' into build-with-musl
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); } |