 
     deinit {
       #if os(Windows)
-        SetConsoleCtrlHandler(signalHandler, false)
+        SetConsoleCtrlHandler(self.signalHandler, false)
         CloseHandle(signalWatchingPipe[1])
       #else
         // Restore the old action and close the write end of pipe.
-        sigaction(SIGINT, &oldAction, nil)
-        close(signalWatchingPipe[1])
+        sigaction(SIGINT, &Self.oldAction, nil)
+        close(Self.signalWatchingPipe[1])
       #endif
         thread.join()
     }

import TSCLibc
import TSCBasic

/// Interrupt signal handling global variables
private var wasInterrupted = false
private var wasInterruptedLock = Lock()
#if os(Windows)
private var signalWatchingPipe: [HANDLE] = [INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE]
#else
private var signalWatchingPipe: [Int32] = [0, 0]
private var oldAction = sigaction()
#endif

/// This class can be used by command line tools to install a handler which
/// should be called when a interrupt signal is delivered to the process.
public final class InterruptHandler {

    /// The thread which waits to be notified when a signal is received.
    let thread: Thread

                var buf: Int8 = 0
              #if os(Windows)
                var n: DWORD = 0
                ReadFile(Self.signalWatchingPipe[1], &buf, 1, &n, nil)
              #else
                let n = read(Self.signalWatchingPipe[0], &buf, 1)
              #endif
                // Pipe closed, nothing to do.
                if n == 0 { break }
                // Read the value of wasInterrupted and set it to false.
                let wasInt = Self.wasInterruptedLock.withLock { () -> Bool in
                    let oldValue = Self.wasInterrupted
                    Self.wasInterrupted = false
                    return oldValue
                }
                // Terminate all processes if was interrupted.
