in src/com/pty4j/unix/UnixPtyProcess.java [206:256]
private void execInPty(String[] command, String[] environment, String workingDirectory, Pty pty, Pty errPty,
@Nullable Integer initialColumns,
@Nullable Integer initialRows) throws IOException {
if (environment == null) {
environment = new String[0];
}
final String slaveName = pty.getSlaveName();
final int masterFD = pty.getMasterFD();
final String errSlaveName = errPty == null ? null : errPty.getSlaveName();
final int errMasterFD = errPty == null ? -1 : errPty.getMasterFD();
// int fdm = pty.get
Reaper reaper = new Reaper(command, environment, workingDirectory, slaveName, masterFD, errSlaveName, errMasterFD, myConsoleMode);
reaper.setDaemon(true);
reaper.start();
// Wait until the subprocess is started or error.
synchronized (this) {
while (pid == 0) {
try {
wait();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
boolean init = Boolean.getBoolean("unix.pty.init") || initialColumns != null || initialRows != null;
if (init) {
int cols = initialColumns != null ? initialColumns : Integer.getInteger("unix.pty.cols", 80);
int rows = initialRows != null ? initialRows : Integer.getInteger("unix.pty.rows", 25);
WinSize size = new WinSize(cols, rows);
// On OSX, there is a race condition with pty initialization
// If we call com.pty4j.unix.Pty.setTerminalSize(com.pty4j.WinSize) too early, we can get ENOTTY
for (int attempt = 0; attempt < 1000; attempt++) {
try {
myPty.setWindowSize(size, this);
break;
}
catch (UnixPtyException e) {
if (e.getErrno() != CLibrary.ENOTTY) {
break;
}
}
}
}
}
if (pid == -1) {
throw new IOException("Exec_tty error:" + reaper.getErrorMessage(), reaper.getException());
}
}