summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2020-11-04 19:58:06 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2020-11-04 20:16:30 -0500
commit8e1394ea49d045127df92b1637a434b444943372 (patch)
treeaa08ff3c8d03974970e6ed515dd7048ec1f289c2
parent0b00b13a423f87bc56c8128e4b9f1c0297990017 (diff)
downloadlighttpd-git-8e1394ea49d045127df92b1637a434b444943372.tar.gz
[core] no graceful-restart-bg on OpenBSD, NetBSD
disable server.graceful-restart-bg on OpenBSD and NetBSD kqueue is not inherited across fork, and OpenBSD and NetBSD do not implement rfork() (implemented on FreeBSD and DragonFly) lighttpd has not implemented rebuilding the kqueues after fork, so server.graceful-restart-bg is disabled on OpenBSD and NetBSD.
-rw-r--r--src/server.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c
index 1acac9bf..83c0241f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -841,7 +841,26 @@ static int server_graceful_state_bg (server *srv) {
* platforms to achieve the same:
* https://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe
*/
+ #if defined(HAVE_KQUEUE)
+ #if defined(__FreeBSD__) || defined(__DragonFly__)
+ /*(must *exclude* rfork RFFDG flag for kqueue to work across rfork)*/
+ pid_t pid = rfork(RFPROC);
+ #else
+ pid_t pid = -1;
+ if (pid < 0) {
+ /* kqueue is not inherited across fork
+ * future: fdevent kqueue and stat_cache kqueue would need to be closed,
+ * re-opened, and active fds re-registered. Not current done.
+ * Need to create some routines like fdevent_reinit_after_fork*/
+ log_error(srv->errh, __FILE__, __LINE__,
+ "server.graceful-restart-bg ignored on OpenBSD and NetBSD "
+ "due to limitation in kqueue inheritance and lacking rfork");
+ return 0;
+ }
+ #endif
+ #else
pid_t pid = fork();
+ #endif
if (pid) { /* original process */
if (pid < 0) return 0;
network_socket_activation_to_env(srv);