Bug 13443 – stdin/stdout/stderr should be accessible from @safe code

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-09T10:33:00Z
Last change time
2016-06-25T05:31:37Z
Keywords
safe
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-09-09T10:33:26Z
Currently, the standard File variables in std.stdio are not accessible from @safe code, because they are declared as __gshared. From looking at the code, it looks like they are indeed not thread-safe - the reference counter is not incremented/decremented atomically.
Comment #1 by lt.infiltrator — 2015-12-03T13:49:39Z
So should the solution be to make them not __gshared; or to fix them to be thread-safe and continue to disallow them in @safe code?
Comment #2 by dlang-bugzilla — 2015-12-03T14:20:22Z
Not sure, but one thing to keep in mind is that C I/O is already implicitly synchronized (see e.g. LockingTextReader/Writer).
Comment #3 by bugzilla — 2016-06-25T00:43:01Z
Yes, they are already synchronized. Perhaps wrap them in an @trusted wrapper.
Comment #4 by bugzilla — 2016-06-25T05:31:37Z
A trusted wrapper doesn't work. Better explanation in https://issues.dlang.org/show_bug.cgi?id=15768 *** This issue has been marked as a duplicate of issue 15768 ***