fix(pcap): fix file descriptor error

This commit is contained in:
2025-10-12 13:06:09 +01:00
parent 80632dd1d9
commit a64d6c6bdb
2 changed files with 2 additions and 8 deletions

View File

@@ -31,12 +31,7 @@ func NewPacketCapture(iface, outputPath string) (*PacketCapture, error) {
fileExists = true
}
var file *os.File
if fileExists {
file, err = os.OpenFile(outputPath, os.O_APPEND, 0644)
} else {
file, err = os.Create(outputPath)
}
file, err := os.OpenFile(outputPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
handle.Close()
return nil, fmt.Errorf("create/open pcap file: %w", err)