I have an app with a goroutine that does this loop. Now I need to stop my application and shutdown the loop. Unfortunately there is no way to do it gracefully. I can do uevent.Close()
in another goroutine but it is racy and causes a panic in bufio.Reader
(see anatol/booster#22):
panic: bufio: reader returned negative count from Read
goroutine 6 [running]:
bufio.(*Reader).fill(0xc000070f68)
/usr/lib/go/src/bufio/bufio.go:103 +0x1dd
bufio.(*Reader).ReadSlice(0xc000070f68, 0x0, 0xc, 0x7f6718544c28, 0xc0003c42f0, 0x0, 0xab0fc0)
/usr/lib/go/src/bufio/bufio.go:360 +0x3d
bufio.(*Reader).collectFragments(0xc000070f68, 0xc000070d00, 0x40d610, 0xc00006b440, 0x30, 0x30, 0x823120, 0xc00005c960, 0x60, 0x7f671854e308, ...)
/usr/lib/go/src/bufio/bufio.go:435 +0x7a
bufio.(*Reader).ReadString(0xc000070f68, 0xc00005c900, 0x7, 0x0, 0xc00011a9d8, 0x0)
/usr/lib/go/src/bufio/bufio.go:483 +0x4c
github.com/s-urbaniak/uevent.(*Decoder).next(...)
/home/anatol/go/pkg/mod/github.com/s-urbaniak/[email protected]/decoder.go:81
github.com/s-urbaniak/uevent.(*Decoder).Decode(0xc000070ed0, 0xc00006b3e0, 0x83cf0f, 0x7)
/home/anatol/go/pkg/mod/github.com/s-urbaniak/[email protected]/decoder.go:42 +0x75
main.udevListener()
/mnt/cold/sources/golang/booster/init/main.go:454 +0x185
created by main.boost
/mnt/cold/sources/golang/booster/init/main.go:782 +0x4bd
Please provide a way to shutdown the uevent loop gracefully.