--- old/src/java.base/unix/native/libjava/Console_md.c 2018-08-24 15:15:37.011607000 +0200 +++ new/src/java.base/unix/native/libjava/Console_md.c 2018-08-24 15:15:35.531578600 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,34 @@ #include "jni_util.h" #include "jvm.h" #include "java_io_Console.h" - #include +#include +#include #include #include +JNIEXPORT jint JNICALL +Java_java_io_Console_width(JNIEnv *env, jobject this) +{ + struct winsize w; + + if (ioctl(0, TIOCGWINSZ, &w) == 0 || ioctl(1, TIOCGWINSZ, &w) == 0 || ioctl(2, TIOCGWINSZ, &w) == 0) { + return w.ws_col; + } + return -1; +} + +JNIEXPORT jint JNICALL +Java_java_io_Console_height(JNIEnv *env, jobject this) +{ + struct winsize w; + + if (ioctl(0, TIOCGWINSZ, &w) == 0 || ioctl(1, TIOCGWINSZ, &w) == 0 || ioctl(2, TIOCGWINSZ, &w) == 0) { + return w.ws_row; + } + return -1; +} + JNIEXPORT jboolean JNICALL Java_java_io_Console_istty(JNIEnv *env, jclass cls) {