{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/24164","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/24164/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/24164/comments","events_url":"https://api.github.com/repos/golang/go/issues/24164/events","html_url":"https://github.com/golang/go/issues/24164","id":300837105,"node_id":"MDU6SXNzdWUzMDA4MzcxMDU=","number":24164,"title":"runtime: closing Darwin FIFO writer does not trigger kqueue event for reader","user":{"login":"stjohnjohnson","id":622065,"node_id":"MDQ6VXNlcjYyMjA2NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/622065?v=4","gravatar_id":"","url":"https://api.github.com/users/stjohnjohnson","html_url":"https://github.com/stjohnjohnson","followers_url":"https://api.github.com/users/stjohnjohnson/followers","following_url":"https://api.github.com/users/stjohnjohnson/following{/other_user}","gists_url":"https://api.github.com/users/stjohnjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/stjohnjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stjohnjohnson/subscriptions","organizations_url":"https://api.github.com/users/stjohnjohnson/orgs","repos_url":"https://api.github.com/users/stjohnjohnson/repos","events_url":"https://api.github.com/users/stjohnjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/stjohnjohnson/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"node_id":"MDU6TGFiZWwzNzM0MDIyODk=","url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false},{"id":199753384,"node_id":"MDU6TGFiZWwxOTk3NTMzODQ=","url":"https://api.github.com/repos/golang/go/labels/OS-Darwin","name":"OS-Darwin","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/62","html_url":"https://github.com/golang/go/milestone/62","labels_url":"https://api.github.com/repos/golang/go/milestones/62/labels","id":2827591,"node_id":"MDk6TWlsZXN0b25lMjgyNzU5MQ==","number":62,"title":"Go1.11","description":"","creator":{"login":"rsc","id":104030,"node_id":"MDQ6VXNlcjEwNDAzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":579,"closed_issues":554,"state":"open","created_at":"2017-10-10T13:39:17Z","updated_at":"2018-06-13T17:13:47Z","due_on":"2018-07-31T07:00:00Z","closed_at":null},"comments":3,"created_at":"2018-02-27T23:45:23Z","updated_at":"2018-06-13T18:43:54Z","closed_at":null,"author_association":"NONE","body":"\r\n### What version of Go are you using (`go version`)?\r\ngo version go1.10 linux/amd64\r\ngo version go1.10 darwin/amd64\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes\r\n\r\n### What did you do?\r\n\r\nRan this script here that reads/writes from a FIFO.  On Linux the reader receives the EOF.  On Darwin it does not.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n    \"bufio\"\r\n    \"fmt\"\r\n    \"os\"\r\n    \"time\"\r\n)\r\n\r\n// @note This is used to get around bufio.Scanner erroring at large lines\r\nfunc readln(r *bufio.Reader) (string, error) {\r\n    var (\r\n        isPrefix = true\r\n        err      error\r\n        line, ln []byte\r\n    )\r\n\r\n    for isPrefix && err == nil {\r\n        line, isPrefix, err = r.ReadLine()\r\n        ln = append(ln, line...)\r\n    }\r\n\r\n    return string(ln), err\r\n}\r\n\r\nfunc reader(filePath string) {\r\n    f, err := os.Open(filePath)\r\n    if err != nil {\r\n        panic(err)\r\n    }\r\n\r\n    reader := bufio.NewReader(f)\r\n    fmt.Print(\"READER >> created\\n\")\r\n\r\n    line, readErr := readln(reader)\r\n\r\n    for readErr == nil {\r\n        fmt.Printf(\"READER >> read 1 line: %+v\\n\", line)\r\n        line, readErr = readln(reader)\r\n    }\r\n\r\n    fmt.Printf(\"READER >> read finished: %+v\\n\", readErr)\r\n}\r\n\r\nfunc writer(filePath string) {\r\n    f, err := os.OpenFile(filePath, os.O_WRONLY, 0600)\r\n\r\n    fmt.Printf(\"WRITER << opened: %+v|%+v\\n\", f, err)\r\n    if err != nil {\r\n        panic(err)\r\n    }\r\n\r\n    fmt.Printf(\"WRITER << encoder created\\n\")\r\n\r\n    for i := 0; i < 3; i++ {\r\n        time.Sleep(1 * time.Second)\r\n        _, err = f.WriteString(fmt.Sprint(\"line\", i, \"\\n\"))\r\n        fmt.Printf(\"WRITER << written line%d, %+v\\n\", i, err)\r\n    }\r\n\r\n    time.Sleep(1 * time.Second)\r\n    err = f.Close()\r\n    fmt.Printf(\"WRITER << closed: %+v\\n\", err)\r\n}\r\n\r\nfunc main() {\r\n    fifo := os.Args[1]\r\n\r\n    fmt.Printf(\"STARTED %s\\n\", fifo)\r\n\r\n    go writer(fifo)\r\n    reader(fifo)\r\n\r\n    fmt.Print(\"ALL DONE\\n\")\r\n}\r\n```\r\n\r\n#### Linux\r\n\r\n```bash\r\ngo version go1.10 linux/amd64\r\nSTARTED /tmp/tmp.6if4ZSWnZ8/fifo\r\nREADER >> created\r\nWRITER << opened: &{file:0xc42008c000}|<nil>\r\nWRITER << encoder created\r\nWRITER << written line0, <nil>\r\nREADER >> read 1 line: line0\r\nWRITER << written line1, <nil>\r\nREADER >> read 1 line: line1\r\nWRITER << written line2, <nil>\r\nREADER >> read 1 line: line2\r\nWRITER << closed: <nil>\r\nREADER >> read finished: EOF\r\nALL DONE\r\n```\r\n\r\n#### Darwin\r\n\r\n```bash\r\ngo version go1.10 darwin/amd64\r\nSTARTED /var/folders/k_/zdt3jb2j7gx1rnf379k_51gh0000gn/T/tmp.ksHGLSvs/fifo\r\nREADER >> created\r\nWRITER << opened: &{file:0xc42009e000}|<nil>\r\nWRITER << encoder created\r\nWRITER << written line0, <nil>\r\nREADER >> read 1 line: line0\r\nWRITER << written line1, <nil>\r\nREADER >> read 1 line: line1\r\nWRITER << written line2, <nil>\r\nREADER >> read 1 line: line2\r\nWRITER << closed: <nil>\r\n^C\r\nsignal: interrupt\r\n```\r\n\r\nRepo for reproduction: https://github.com/stjohnjohnson/golang-eof-fifo\r\n\r\n### Notes\r\n\r\nWas able to reproduce it as far back as `go1.9 darwin/amd64` using asdf.  Last working version was `go1.8.7 darwin/amd64`.\r\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/397044248","html_url":"https://github.com/golang/go/issues/24164#issuecomment-397044248","issue_url":"https://api.github.com/repos/golang/go/issues/24164","id":397044248,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzA0NDI0OA==","user":{"login":"ianlancetaylor","id":3194333,"node_id":"MDQ6VXNlcjMxOTQzMzM=","avatar_url":"https://avatars2.githubusercontent.com/u/3194333?v=4","gravatar_id":"","url":"https://api.github.com/users/ianlancetaylor","html_url":"https://github.com/ianlancetaylor","followers_url":"https://api.github.com/users/ianlancetaylor/followers","following_url":"https://api.github.com/users/ianlancetaylor/following{/other_user}","gists_url":"https://api.github.com/users/ianlancetaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/ianlancetaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianlancetaylor/subscriptions","organizations_url":"https://api.github.com/users/ianlancetaylor/orgs","repos_url":"https://api.github.com/users/ianlancetaylor/repos","events_url":"https://api.github.com/users/ianlancetaylor/events{/privacy}","received_events_url":"https://api.github.com/users/ianlancetaylor/received_events","type":"User","site_admin":false},"created_at":"2018-06-13T18:43:53Z","updated_at":"2018-06-13T18:43:53Z","author_association":"CONTRIBUTOR","body":"I can confirm that on MacOS 16.3.0 closing the last writer to a FIFO does not trigger a kqueue event for the reader.  In Go's implementation, that causes the reader to block indefinitely.\r\n\r\nThere is a Stack Overflow questions that mentions this, with no solution offered: https://stackoverflow.com/questions/49481723/difference-in-kqueue-handling-of-fifos-between-mac-os-and-freebsd .\r\n\r\nMy best suggestion at this point is that on Darwin we will have to avoid treating fifos as pollable."}}
{"actor":{"display_login":"ianlancetaylor"}}