mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Update server shutdown procedure.
Ignore SIGINT, honor TOR_PT_EXIT_ON_STDIN_CLOSE.
This commit is contained in:
parent
bdc1798adb
commit
019e2cea23
2 changed files with 26 additions and 14 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -378,6 +379,16 @@ func main() {
|
|||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGTERM)
|
||||
|
||||
if os.Getenv("TOR_PT_EXIT_ON_STDIN_CLOSE") == "1" {
|
||||
// This environment variable means we should treat EOF on stdin
|
||||
// just like SIGTERM: https://bugs.torproject.org/15435.
|
||||
go func() {
|
||||
io.Copy(ioutil.Discard, os.Stdin)
|
||||
log.Printf("synthesizing SIGTERM because of stdin close")
|
||||
sigChan <- syscall.SIGTERM
|
||||
}()
|
||||
}
|
||||
|
||||
// keep track of handlers and wait for a signal
|
||||
sig = nil
|
||||
for sig == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue