[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Handle TOR_PT_EXIT_ON_STDIN_CLOSE.
commit f418ec7a8591227c7c735450db9024bbf4751ef4
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Thu Jun 29 15:23:40 2017 -0700
Handle TOR_PT_EXIT_ON_STDIN_CLOSE.
---
client/snowflake.go | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/client/snowflake.go b/client/snowflake.go
index ad29aea..f632e5e 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -5,6 +5,7 @@ import (
"errors"
"flag"
"io"
+ "io/ioutil"
"log"
"net"
"os"
@@ -200,6 +201,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 {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits