Skip to content

[receiver/filelog] Open files on Windows with FILE_SHARE_DELETE #32037

@BinaryFissionGames

Description

@BinaryFissionGames

Component(s)

receiver/filelog

Is your feature request related to a problem? Please describe.

On Windows, files open by the collector cannot be moved/deleted. It would be nice if the collector opened a file with the FILE_SHARE_DELETE share mode

Describe the solution you'd like

When opening files on Windows, with the CreateFile(W|A) function (docs here), a share mode is passed in that dictates how other processes may access this file.

The documentation calls out 3 values that may be combined, "FILE_SHARE_DELETE", "FILE_SHARE_READ", and "FILE_SHARE_WRITE". In Go's default os.Open implementation, "FILE_SHARE_READ|FILE_SHARE_WRITE" is used as this parameter, but having "FILE_SHARE_DELETE" would be useful, because it would allow other processes to delete or rename the file without having to shut down the collector.

It should be possible to construct a file handle using the CreateFile syscall, and turn it into an os.File by using syscall.CreateFile to create the handle, then wrap it using windows.NewFile (the fd here is not of type syscall.Handle, but the implementation is clear that fd should be a handle)

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needednever staleIssues marked with this label will be never staled and automatically removedreceiver/filelog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions