@@ -1175,7 +1175,22 @@ should_show_ports(void)
{
static int interactive = -1;
if (interactive == -1) {
+#ifdef _WIN32
+ /* Get the handle to the file descriptor */
+ HANDLE h = (HANDLE)_get_osfhandle(STDOUT_FILENO);
+ DWORD st;
+ if (!isatty(STDOUT_FILENO)) {
+ /* The file descriptor is not a character device */
+ interactive = 0;
+ } else if (h == INVALID_HANDLE_VALUE || !GetConsoleMode(h, &st)) {
+ /* The file descriptor is broken or not a console buffer */
+ interactive = 0;
+ } else {
+ interactive = 1;
+ }
+#else
interactive = isatty(STDOUT_FILENO);
+#endif
}
return use_port_names > 0 || (use_port_names == -1 && interactive);
A lot of tests are failing, due to the open flow ports being outputted using names instead of numbers. i.e.: http://64.119.130.115/ovs/beb75a40fdc295bfd6521b0068b4cd12f6de507c/testsuite.dir/0464/testsuite.log.gz The issues encountered above is because 'monitor' with 'detach' arguments are specified, that in turn will call 'close_standard_fds' (https://github.com/openvswitch/ovs/blob/master/lib/daemon-unix.c#L472) which will create a duplicate fd over '/dev/null' on Linux and 'nul' on Windows. 'isatty' will be called on those FDs. What POSIX standard says: http://pubs.opengroup.org/onlinepubs/009695399/functions/isatty.html 'The isatty() function shall test whether fildes, an open file descriptor, is associated with a terminal device.' What MSDN says: https://msdn.microsoft.com/en-us/library/f4s0ddew(VS.80).aspx 'The _isatty function determines whether fd is associated with a character device (a terminal, console, printer, or serial port).' This patch adds another check using 'GetConsoleMode' https://msdn.microsoft.com/en-us/library/windows/desktop/ms683167(v=vs.85).aspx which will fail if the handle pointing to the file descriptor is not associated to a console. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> --- utilities/ovs-ofctl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)