Skip to content

Doesn't work on macOS unless -N is specified #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
neongreen opened this issue Aug 21, 2019 · 1 comment
Open

Doesn't work on macOS unless -N is specified #89

neongreen opened this issue Aug 21, 2019 · 1 comment

Comments

@neongreen
Copy link

neongreen commented Aug 21, 2019

When using forever $ threadDelay 1000000, I needed both -threaded and -with-rtsopts=-N to get it to work. When using forever $ getLine, I only needed -threaded. Perhaps this should be mentioned in the docs.

    forkIO $ FSNotify.withManager $ \manager -> do
        directory <- takeDirectory <$> makeAbsolute (settingsRoot settings)
        let predicate = const True
        FSNotify.watchDir manager directory predicate print
        forever $ threadDelay 1000000
@thomasjm
Copy link
Contributor

This is similar in spirit to #50.

The GHC docs say that omitting -N is equivalent to passing -N1. I don't totally understand why your program wouldn't work when run with a single Haskell capability. Does it fail to print anything at all? I'd expect the main thread to yield to the callback thread in between threadDelay 1000000 calls but maybe some deadlock is happening with foreign function calls.

I'm not sure if there are any checks we can add to the code to prevent this, the same way we did to check for -threaded on Windows. Like you said, doing non-blocking stuff in the event handler with -N1 is a valid way to use this library. But a note in the docs about threading pitfalls sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants