logo       

openFile "/dev/null" WriteMode fails: msg#00103

lang.haskell.glasgow.bugs

Subject: openFile "/dev/null" WriteMode fails

Hello.

The following program produces an "invalid operation" IOError:

import IO

main =
do h <- openFile "/dev/null" WriteMode
hPutStrLn h "bla"
`catch` (\ioe -> putStrLn (show ioe))


When called:

/dev/null: openFile: invalid argument (Invalid argument)


It works with AppendMode. I'm not sure if that's to be considered a bug. It's
counter-intuitive, and openFile shouldn't fail with "invalid operation",
since the API docs (and the Language Report) say:

This operation may fail with:

* isAlreadyInUseError if the file is already open and cannot be reopened;
* isDoesNotExistError if the file does not exist; or
* isPermissionError if the user does not have permission to open the file.

I'm using GHC 6.4 on Debian Linux.

Bye,
V.W.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise