From b78b52c4cd7f843da3ff0848a3430afbd401bdf2 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 20 Jul 2026 20:42:29 +0300 Subject: [PATCH] blockcheck2: use cygstart in windows to avoid fork problems (without cygwin rebase) --- blockcheck2.sh | 22 ++++++++++++++++++---- docs/changes.txt | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/blockcheck2.sh b/blockcheck2.sh index 97d0916..d741eaa 100755 --- a/blockcheck2.sh +++ b/blockcheck2.sh @@ -942,22 +942,36 @@ pktws_ipt_unprepare_udp() pktws_start() { + local pidfile case "$UNAME" in Linux) "$NFQWS2" --uid $WS_UID:$WS_GID --fwmark=$DESYNC_MARK --qnum=$QNUM --lua-init=@"$ZAPRET_BASE/lua/zapret-lib.lua" --lua-init=@"$ZAPRET_BASE/lua/zapret-antidpi.lua" "$@" >/dev/null & + PID=$! + # give some time to initialize + minsleep ;; FreeBSD|OpenBSD) "$DVTWS2" --port=$IPFW_DIVERT_PORT --lua-init=@"$ZAPRET_BASE/lua/zapret-lib.lua" --lua-init=@"$ZAPRET_BASE/lua/zapret-antidpi.lua" "$@" >/dev/null & + PID=$! + # give some time to initialize + minsleep ;; CYGWIN) + pidfile="/tmp/blockcheck_cygpid_$$" + # avoid fork # allow multiple PKTWS instances with the same wf filter but different ipset # some methods require empty acks - "$WINWS2" --wf-dup-check=0 --wf-tcp-empty=1 $WF --ipset="$IPSET_FILE" --lua-init=@"$ZAPRET_BASE/lua/zapret-lib.lua" --lua-init=@"$ZAPRET_BASE/lua/zapret-antidpi.lua" "$@" >/dev/null & + cygstart --hide "$WINWS2" --pidfile="$pidfile" --wf-dup-check=0 --wf-tcp-empty=1 $WF --ipset="$IPSET_FILE" --lua-init=@"$ZAPRET_BASE/lua/zapret-lib.lua" --lua-init=@"$ZAPRET_BASE/lua/zapret-antidpi.lua" "$@" >/dev/null & + # give some time to initialize + minsleep + if [ -f "$pidfile" ]; then + read PID <"$pidfile" + rm -f "$pidfile" + else + echo "pktws failed to initialize within specified time !!" + fi ;; esac - PID=$! - # give some time to initialize - minsleep } ws_kill() { diff --git a/docs/changes.txt b/docs/changes.txt index 80e478f..95150dd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -313,4 +313,4 @@ v0.9.4.3 * nfqws2: accept string or function in timer_set(). remember function as a function, not as a string. * nfqws2: limit delayed packet queue to 64 packets (anti-ddos) * init.d: add udp ports range 19294-19344 to discord media - +* blockcheck2: use cygstart in windows to avoid fork problems (without cygwin rebase)