Skip to content

Commit

Permalink
Windows: Avoid race condition when starting input pump thread
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-gh committed Sep 20, 2017
1 parent ec009b5 commit 938eeca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public JansiWinSysTerminal(String name, boolean nativeSignals) throws IOExceptio
public JansiWinSysTerminal(String name, int codepage, boolean nativeSignals, SignalHandler signalHandler) throws IOException {
super(new WindowsAnsiWriter(new BufferedWriter(new JansiWinConsoleWriter())),
name, codepage, nativeSignals, signalHandler);

// Start input pump thread
pump.start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public JnaWinSysTerminal(String name, int codepage, boolean nativeSignals, Signa
super(new WindowsAnsiWriter(new BufferedWriter(new JnaWinConsoleWriter(consoleOut)), consoleOut),
name, codepage, nativeSignals, signalHandler);
strings.put(InfoCmp.Capability.key_mouse, "\\E[M");

// Start input pump thread
pump.start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public AbstractWindowsTerminal(Writer writer, String name, int codepage, boolean
}
pump = new Thread(this::pump, "WindowsStreamPump");
pump.setDaemon(true);
pump.start();
// This is called by the JNA/Jansi terminal implementation to avoid
// race conditions if they do initialization in their constructor
//pump.start();
closer = this::close;
ShutdownHooks.add(closer);
}
Expand Down

0 comments on commit 938eeca

Please sign in to comment.