How to fully release Windows file handle

54 views
Skip to first unread message

Bryan Richardson

unread,
Sep 11, 2021, 4:59:44 PM9/11/21
to golang-nuts
I'm working with this code[1] to connect to a virtio virtual serial port in a Windows VM running in QEMU. When the program first starts up, it has no problem dialing the serial port (at path), and I can stop and restart the program without issue. However, if I try to close then dial the serial port again, I get a Windows "Access denied" error returned by the dialSerial function.

Is there any way to fully release the file handle so I can reconnect to it without having to restart the application? I'm needing to do this when I detect a disconnect on the other end so communications can be re-established.

[1] https://github.com/sandia-minimega/minimega/blob/master/src/miniccc/virtio_windows.go
Reply all
Reply to author
Forward
0 new messages