{"action":"created","issue":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/4","repository_url":"https://api.github.com/repos/ndmitchell/shake","labels_url":"https://api.github.com/repos/ndmitchell/shake/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/ndmitchell/shake/issues/4/comments","events_url":"https://api.github.com/repos/ndmitchell/shake/issues/4/events","html_url":"https://github.com/ndmitchell/shake/issues/4","id":12203863,"number":4,"title":"Lock the .database file on Linux","user":{"login":"ndmitchell","id":1651197,"avatar_url":"https://avatars1.githubusercontent.com/u/1651197?v=4","gravatar_id":"","url":"https://api.github.com/users/ndmitchell","html_url":"https://github.com/ndmitchell","followers_url":"https://api.github.com/users/ndmitchell/followers","following_url":"https://api.github.com/users/ndmitchell/following{/other_user}","gists_url":"https://api.github.com/users/ndmitchell/gists{/gist_id}","starred_url":"https://api.github.com/users/ndmitchell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndmitchell/subscriptions","organizations_url":"https://api.github.com/users/ndmitchell/orgs","repos_url":"https://api.github.com/users/ndmitchell/repos","events_url":"https://api.github.com/users/ndmitchell/events{/privacy}","received_events_url":"https://api.github.com/users/ndmitchell/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2013-03-19T21:49:30Z","updated_at":"2018-05-01T10:36:54Z","closed_at":"2015-08-24T15:56:10Z","author_association":"OWNER","body":"Evan Laforge reported that Shake does not lock the .database file on Linux, which means that you can run two concurrent copies of Shake against the same database, and they damage each other. Evan says: you can lock with files, which has a nice '80s feel to it, but there is also fcntl().  It looks like the stdlib has a binding to fcntl, though poorly documented:\n\n``` haskell\nimport qualified System.Environment as Environment\nimport qualified System.Posix.IO as IO\nimport qualified System.IO as IO\n\nmain :: IO ()\nmain = do\n    [fn] <- Environment.getArgs\n    fd <- IO.openFd fn IO.ReadWrite Nothing IO.defaultFileFlags\n    IO.waitToSetLock fd (IO.WriteLock, IO.AbsoluteSeek, 0, 0)\n    print \"locked\"\n    getLine\n    return ()\n```\n\nThis one blocks, you can also call IO.setLock and catch the exception\n(ick) if it fails. Historically you would use lock files because fcntl wasn't reliable\nover NFS, but I hear that has been fixed at some point.  I'm hardly an\nexpert though.\n"},"comment":{"url":"https://api.github.com/repos/ndmitchell/shake/issues/comments/385643553","html_url":"https://github.com/ndmitchell/shake/issues/4#issuecomment-385643553","issue_url":"https://api.github.com/repos/ndmitchell/shake/issues/4","id":385643553,"user":{"login":"bitc","id":996487,"avatar_url":"https://avatars3.githubusercontent.com/u/996487?v=4","gravatar_id":"","url":"https://api.github.com/users/bitc","html_url":"https://github.com/bitc","followers_url":"https://api.github.com/users/bitc/followers","following_url":"https://api.github.com/users/bitc/following{/other_user}","gists_url":"https://api.github.com/users/bitc/gists{/gist_id}","starred_url":"https://api.github.com/users/bitc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitc/subscriptions","organizations_url":"https://api.github.com/users/bitc/orgs","repos_url":"https://api.github.com/users/bitc/repos","events_url":"https://api.github.com/users/bitc/events{/privacy}","received_events_url":"https://api.github.com/users/bitc/received_events","type":"User","site_admin":false},"created_at":"2018-05-01T10:36:54Z","updated_at":"2018-05-01T10:36:54Z","author_association":"NONE","body":"Looks like `runAfter` was  recently added. Works like a charm! :+1: "}}
{"actor":{"display_login":"bitc"}}