Skip to content

Missing Remove Event when file handle open before for Linux #194

@lbgogo88

Description

@lbgogo88

Before reporting an issue, please ensure you are using the latest release of fsnotify.

Which operating system (GOOS) and version are you using?

Linux: lsb_release -a
macOS: sw_vers
Windows: systeminfo | findstr /B /C:OS

Linux:
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.8 (Final)
Release: 5.8
Codename: Final

Please describe the issue that occurred.

Missing Remove Event when got file handle already open before. See the sample.

And I review the fsnotify code(fsnotify/inotify.go/func newEvent) found that unix.IN_ATTRIB was catched then e.Op was set to Chmod when rm -f $filename;echo >$filename done.

After that the event was ignored by "func ignoreLinux"

For this reason, I must watch the directory to walk around.

Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.


package main

import (
        "github.com/fsnotify/fsnotify"
        "os"
        "fmt"
)

func main() {
        var err error
        path := os.Args[1]
        watcher,_ := fsnotify.NewWatcher()

        watcher.Add(path)
        done := make(chan bool)

        os.Open(path)
        go func(){
                var ev fsnotify.Event
                for {
                        select {
                        case ev = <-watcher.Events:
                        case err = <-watcher.Errors:
                                fmt.Println("##ERR",err)
                        }
                        fmt.Println(ev)
                }
        }()

        <-done
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions