Skip to content
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

Unexpected behavior when closing io.PipeReader #754

Open
spongehah opened this issue Aug 30, 2024 · 0 comments · May be fixed by #773
Open

Unexpected behavior when closing io.PipeReader #754

spongehah opened this issue Aug 30, 2024 · 0 comments · May be fixed by #773

Comments

@spongehah
Copy link
Contributor

The code provided below is a minimal reproduction of this issue.

package main

import (
	"fmt"
	"io"
	"time"
)

func main() {
	reader, writer := io.Pipe()

	go func() {
		println("goroutine start")
		_, err := writer.Write([]byte("hello"))
		if err != nil {
			fmt.Println(err)
			writer.Close()
		}
		println("goroutine end")
	}()

	//c.Usleep(2 * 1000 * 1000)
	time.Sleep(2 * time.Second)
	reader.Close()
	//c.Usleep(2 * 1000 * 1000)
	time.Sleep(2 * time.Second)
}

Unexpected output: (llgo)

llgo run .
goroutine start

Expected output(go):

go run .
goroutine start
io: read/write on closed pipe
goroutine end
@visualfc visualfc linked a pull request Sep 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant