Skip to content

Commit

Permalink
Fix remote terminal on linux/bsd (fixes #962) (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Apr 17, 2024
1 parent 4545ba7 commit ed52706
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static NativeWinSysTerminal createTerminal(
console = GetStdHandle(STD_ERROR_HANDLE);
break;
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
java.lang.foreign.MemorySegment outMode = allocateInt(arena);
if (GetConsoleMode(console, outMode) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static FreeBsdNativePty current(TerminalProvider provider, SystemStream s
return new FreeBsdNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname());
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static LinuxNativePty current(TerminalProvider provider, SystemStream sys
return new LinuxNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname());
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand All @@ -55,15 +55,18 @@ public static LinuxNativePty open(TerminalProvider provider, Attributes attr, Si
}
String name = new String(buf, 0, len);
return new LinuxNativePty(
provider,
null,
master[0],
newDescriptor(master[0]),
slave[0],
newDescriptor(slave[0]),
2,
FileDescriptor.err,
name);
provider, null, master[0], newDescriptor(master[0]), slave[0], newDescriptor(slave[0]), name);
}

public LinuxNativePty(
TerminalProvider provider,
SystemStream systemStream,
int master,
FileDescriptor masterFD,
int slave,
FileDescriptor slaveFD,
String name) {
super(provider, systemStream, master, masterFD, slave, slaveFD, name);
}

public LinuxNativePty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static OsXNativePty current(TerminalProvider provider, SystemStream syste
FileDescriptor.err,
ttyname());
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static FreeBsdNativePty current(TerminalProvider provider, SystemStream s
return new FreeBsdNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(0));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static LinuxNativePty current(TerminalProvider provider, SystemStream sys
return new LinuxNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(0));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static OsXNativePty current(TerminalProvider provider, SystemStream syste
return new OsXNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(0));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static SolarisNativePty current(TerminalProvider provider, SystemStream s
return new SolarisNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(0));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static FreeBsdNativePty current(TerminalProvider provider, SystemStream s
return new FreeBsdNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(2));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static LinuxNativePty current(TerminalProvider provider, SystemStream sys
return new LinuxNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(2));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand All @@ -55,15 +55,18 @@ public static LinuxNativePty open(TerminalProvider provider, Attributes attr, Si
}
String name = new String(buf, 0, len);
return new LinuxNativePty(
provider,
null,
master[0],
newDescriptor(master[0]),
slave[0],
newDescriptor(slave[0]),
2,
FileDescriptor.err,
name);
provider, null, master[0], newDescriptor(master[0]), slave[0], newDescriptor(slave[0]), name);
}

public LinuxNativePty(
TerminalProvider provider,
SystemStream systemStream,
int master,
FileDescriptor masterFD,
int slave,
FileDescriptor slaveFD,
String name) {
super(provider, systemStream, master, masterFD, slave, slaveFD, name);
}

public LinuxNativePty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static OsXNativePty current(TerminalProvider provider, SystemStream syste
FileDescriptor.err,
ttyname(2));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static SolarisNativePty current(TerminalProvider provider, SystemStream s
return new SolarisNativePty(
provider, systemStream, -1, null, 0, FileDescriptor.in, 2, FileDescriptor.err, ttyname(2));
default:
throw new IllegalArgumentException("Unsupport stream for console: " + systemStream);
throw new IllegalArgumentException("Unsupported stream for console: " + systemStream);
}
} catch (IOException e) {
throw new IOException("Not a tty", e);
Expand All @@ -55,15 +55,7 @@ public static SolarisNativePty open(TerminalProvider provider, Attributes attr,
}
String name = new String(buf, 0, len);
return new SolarisNativePty(
provider,
null,
master[0],
newDescriptor(master[0]),
slave[0],
newDescriptor(slave[0]),
2,
FileDescriptor.err,
name);
provider, null, master[0], newDescriptor(master[0]), slave[0], newDescriptor(slave[0]), name);
}

public SolarisNativePty(
Expand Down

0 comments on commit ed52706

Please sign in to comment.