[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [meek/master] Synthesize a SIGTERM on stdin close.



commit 8611e7da4bd50d2849daeabe0013576117ae613e
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Mon Apr 7 23:30:12 2014 -0700

    Synthesize a SIGTERM on stdin close.
---
 meek-client-torbrowser/main.go |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meek-client-torbrowser/main.go b/meek-client-torbrowser/main.go
index 8890f6d..c4989c3 100644
--- a/meek-client-torbrowser/main.go
+++ b/meek-client-torbrowser/main.go
@@ -141,6 +141,18 @@ 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
+	// processterminate-buffer, it is instead processterminate-buffer that
+	// is killed, and we can detect that event by that our stdout 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)
 	err = logSignal(meekClientCmd.Process, sig)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits