Florian Obser <flor...@openbsd.org> wrote: > On 2023-04-07 10:51 -04, Dave Voutila <d...@sisu.io> wrote: > > In vmd, the vmm process forks to create the resulting vm process. After > > this fork, the vmm parent process closes all the file descriptors > > pointing to the vm's devices (cdrom, kernel, disks, nics, etc.). > > > > The logic was a bit funky, so this change relies on the fact we can > > attempt the close(2) call and use its success/failure to determine if we > > have an fd to mark -1 in the vm structure. (I guess we could just > > blindly set them to -1 post-close, but this feels more sensical to me.) > > > > this will create some noise in ktrace every time you pass -1 to close(2) > you'll see > > CALL close(-1) > RET close -1 errno 9 Bad file descriptor > > Not a vmd user and I don't plan to hack on it any time soon, so > *shrug*.
And also, have you considered EINTR? I prefer if you keep state in the application.