[ruby-core:81015] [Ruby trunk Bug#13546] std steams are closed in Windows app.

From: aepifanov@...
Date: 2017-05-06 22:48:00 UTC
List: ruby-core #81015
Issue #13546 has been reported by alex (Alex Epifanov).

----------------------------------------
Bug #13546: std steams are closed in Windows app.
https://bugs.ruby-lang.org/issues/13546

* Author: alex (Alex Epifanov)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.3.3
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
We are embedding Ruby VM into a windows app ( msvc2015 CRT ). VM fails to initialize in Init_IO with 'closed stream', when initing stdin, stdout and stderr. Debugging shows that fileno() call for stdin and stderr returns -2 value and it is not and error according to MSDN:

https://msdn.microsoft.com/en-us/en-en/library/zs6wbdhx.aspx
"If stdout or stderr is not associated with an output stream (for example, in a Windows application without a console window), the file descriptor returned is -2. In previous versions, the file descriptor returned was -1. This change allows applications to distinguish this condition from an error."

Applying following patch to rb_io_check_closed seems to resolve the issue:

#ifdef _WIN32
    if ((fptr->fd < 0) && (fptr->fd != -2) ) {
#else
    if (fptr->fd < 0) {
#endif
	rb_raise(rb_eIOError, closed_stream);
    }




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next