commit 7ce93df22d535a3b2d6bc60df53c3435a002fdee
Author: David Fifield <[email protected]>
Date:   Tue Apr 8 12:04:38 2014 -0700

    Do the exit-on-stdin-EOF trick on Windows only.
    
    It looks like stdin gets closed by tor, so on other platforms without
    terminateprocess-buffer, the program was exiting immediately.
---
 meek-client-torbrowser/linux.go   |    2 ++
 meek-client-torbrowser/mac.go     |    2 ++
 meek-client-torbrowser/main.go    |   24 +++++++++++++-----------
 meek-client-torbrowser/windows.go |    3 +++
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/meek-client-torbrowser/linux.go b/meek-client-torbrowser/linux.go
index 73e363a..04d17c8 100644
--- a/meek-client-torbrowser/linux.go
+++ b/meek-client-torbrowser/linux.go
@@ -5,6 +5,8 @@
 
 package main
 
+var exitOnStdinEOF = false
+
 var firefoxPath = "Browser/firefox"
 var firefoxProfilePath = "Data/Browser/profile.meek-http-helper"
 var meekClientPath = "Tor/PluggableTransports/meek-client"
diff --git a/meek-client-torbrowser/mac.go b/meek-client-torbrowser/mac.go
index 6830da1..8791403 100644
--- a/meek-client-torbrowser/mac.go
+++ b/meek-client-torbrowser/mac.go
@@ -5,6 +5,8 @@
 
 package main
 
+var exitOnStdinEOF = false
+
 var firefoxPath = "../Contents/MacOS/TorBrowser.app/Contents/MacOS/firefox"
 var firefoxProfilePath = "../Data/Browser/profile.meek-http-helper"
 var meekClientPath = "PluggableTransports/meek-client"
diff --git a/meek-client-torbrowser/main.go b/meek-client-torbrowser/main.go
index ae98328..1d55eff 100644
--- a/meek-client-torbrowser/main.go
+++ b/meek-client-torbrowser/main.go
@@ -148,17 +148,19 @@ func main() {
        }
        defer logKill(meekClientCmd.Process)
 
-       // On Windows, we don't get a SIGINT or SIGTERM, rather we are killed
-       // without a chance to clean up our subprocesses. When run inside
-       // terminateprocess-buffer, it is instead terminateprocess-buffer that
-       // is killed, and we can detect that event by that our stdin gets
-       // closed.
-       // https://trac.torproject.org/projects/tor/ticket/9330
-       go func() {
-               io.Copy(ioutil.Discard, os.Stdin)
-               log.Printf("synthesizing SIGTERM because of stdin close")
-               sigChan <- syscall.SIGTERM
-       }()
+       if exitOnStdinEOF {
+               // On Windows, we don't get a SIGINT or SIGTERM, rather we are 
killed
+               // without a chance to clean up our subprocesses. When run 
inside
+               // terminateprocess-buffer, it is instead 
terminateprocess-buffer that
+               // is killed, and we can detect that event by that our stdin 
gets
+               // closed.
+               // https://trac.torproject.org/projects/tor/ticket/9330
+               go func() {
+                       io.Copy(ioutil.Discard, os.Stdin)
+                       log.Printf("synthesizing SIGTERM because of stdin 
close")
+                       sigChan <- syscall.SIGTERM
+               }()
+       }
 
        sig := <-sigChan
        log.Printf("sig %s", sig)
diff --git a/meek-client-torbrowser/windows.go 
b/meek-client-torbrowser/windows.go
index ed590d8..5e8ea0d 100644
--- a/meek-client-torbrowser/windows.go
+++ b/meek-client-torbrowser/windows.go
@@ -5,6 +5,9 @@
 
 package main
 
+// Workaround for process termination on Windows only.
+var exitOnStdinEOF = true
+
 var firefoxPath string = "Browser/firefox.exe"
 var firefoxProfilePath = "Data/Browser/profile.meek-http-helper"
 var meekClientPath = "Tor/PluggableTransports/meek-client.exe"



_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to