Commit c03acac8 authored by David Fifield's avatar David Fifield
Browse files

Add TOR_PT_EXIT_ON_STDIN_CLOSE to dummy example programs.

parent a3ad5df6
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ package main

import (
	"io"
	"io/ioutil"
	"net"
	"os"
	"os/signal"
@@ -116,6 +117,15 @@ 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)
			sigChan <- syscall.SIGTERM
		}()
	}

	// keep track of handlers and wait for a signal
	sig = nil
	for sig == nil {
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ package main

import (
	"io"
	"io/ioutil"
	"net"
	"os"
	"os/signal"
@@ -108,6 +109,15 @@ 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)
			sigChan <- syscall.SIGTERM
		}()
	}

	// keep track of handlers and wait for a signal
	sig = nil
	for sig == nil {