Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,870
    • Issues 4,870
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 453
    • Merge requests 453
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #4363
Closed
Open
Created Oct 04, 2010 by jystic@trac-jystic

openFile sharing permissions are inconsistent across platforms

System.IO.openFile seems to have inconsistent behaviour across platforms regarding file sharing permissions.

Given this program:

{-# LANGUAGE CPP #-}

import System.IO
import System.Process

main = do
    h <- openFile "file.txt" WriteMode
    hPutStrLn h "Success! I can see the file's contents."
    hFlush h
#ifdef mingw32_HOST_OS
    system "type file.txt"
#else
    system "cat file.txt"
#endif
    hClose h

Running under Ubuntu 10.04 / GHC 6.12.1, I get:

$ runghc openFile.hs
Success! I can see the file's contents.

Running under Windows 7 / GHC 6.12.3, I get:

> runghc openFile.hs
The process cannot access the file because it is being used by another process.

In my opinion the behaviour exhibited by Linux is preferable because it allows for log files to be written by long running processes. These log files can then be inspected externally while the Haskell process is still running.

The Snap Framework (snapframework.com) does this and it works great on Linux / Mac OS, but on Windows the log files cannot be viewed until after the server is shut down.

Trac metadata
Trac field Value
Version 6.12.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking