2 # Allow gitweb.cgi to be run from a fastcgi server that does
3 # not really support periodic "garbage collection" exits
4 # (even on an exit status of 0) without losing fastcgi requests.
5 # Signals are forwarded in both directions.
8 handle_sig
() { [ -z "$bg" ] ||
kill -$1 "$bg" 2>/dev
/null
; }
9 # backgrounding the cgi with '&' causes it to ignore SIGINT and SIGQUIT
10 # therefore we redirect INT to TERM and QUIT to ABRT when forwarding those
11 trap 'handle_sig HUP' HUP
12 trap 'handle_sig ABRT' ABRT QUIT
13 trap 'handle_sig PIPE' PIPE
14 trap 'handle_sig ALRM' ALRM
15 trap 'handle_sig TERM' TERM INT
16 trap 'handle_sig USR1' USR1
17 trap 'handle_sig USR2' USR2
20 (exec 0<&3 3<&-; exec "$cgiroot/gitweb.cgi" "$@")&
26 kill -0 "$bg" 2>/dev
/null ||
break
27 # was a signal to self that's now been forwarded
28 # go around the loop again
31 [ "${ec:-0}" = "0" ] ||
break
32 # was a gitweb "garbage collection" exit
33 # go around the loop again and restart gitweb
35 trap - HUP INT QUIT ABRT PIPE ALRM TERM USR1 USR2
36 if [ "${ec:-0}" -gt 128 ] && [ "${ec:-0}" -lt 160 ]; then