[GHC] #11180: A program writing to a read-only stdout should not succeed
GHC
ghc-devs at haskell.org
Tue Dec 8 19:40:44 UTC 2015
#11180: A program writing to a read-only stdout should not succeed
-------------------------------------+-------------------------------------
Reporter: thomie | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
In the shell, redirection of file descriptors can be read-only (<), write-
only (>), or read-write (<>).
A program trying to write to stdout, while stdout is redirected read-only,
currently exits with exit code 0.
{{{
$ cat hello.hs
main = print "hello world"
$ ghc hello.hs
...
$ ./hello 1< /dev/null; echo Exit status: $?
Exit status: 0
}}}
This should however show some error message, and return some non-zero
error message, because the write never succeeds.
Note that this example is different from `./hello 1> /dev/null`, which
rightfully does succeed.
As suggested by this [http://roscidus.com/blog/blog/2013/06/09/choosing-a
-python-replacement-for-0install/ blog post]:
> "If you’re not sure why this is important, imagine the command is
`dump-database > backup` and the filesystem is full."
Supposedly OCaml gets this right.
For reference, from my bash man page:
> *Redirecting Input*
>
> Redirection of input causes the file whose name results from the
expansion of word to be opened for reading on file descriptor n, or the
standard input (file descriptor 0) if n is not specified.
>
> The general format for redirecting input is:
>
> [n]<word
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11180>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list