Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Double events #14

Closed
larzconwell opened this issue Aug 11, 2012 · 2 comments
Closed

Double events #14

larzconwell opened this issue Aug 11, 2012 · 2 comments

Comments

@larzconwell
Copy link

On Linux 64bit, I'm getting double events on all events. I'm not sure if other platforms are problematic.

Here's the code that I used to test:

package main

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

func main() {
    watcher, err := fsnotify.NewWatcher()
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    err = watcher.WatchFlags("/home/larz/Desktop/test.go", fsnotify.FSN_MODIFY)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    for {
        select {
        case event := <-watcher.Event:
            fmt.Println(event)
        case err := <-watcher.Error:
            fmt.Println(err)
            os.Exit(1)
        }
    }
}

Here's the output while running:

%:Desktop ⵗ go run test.go                                                 
"/home/larz/Desktop/test.go": MODIFY
"/home/larz/Desktop/test.go": MODIFY 

I only modified it once, so I'm not sure why it would be doing it twice.

@howeyc
Copy link
Owner

howeyc commented Aug 11, 2012

I'm not sure I can fix the issue as all I have at the moment are 32bit Linux machines to test on.

But, what I did notice is that when running your test and doing and echo (echo "bam" >> test.go) created 1 event, but using a text editor (vi and :wq) created 2. Perhaps text editors do an attribute change as well as a modify?

I'm not sure what's going on, could you provide more information?

@larzconwell
Copy link
Author

Ah I did the same test doing echo "sdfsdf" >> test.go and it only triggered one event.

I think editors are doing an extra modification then.

I think this can be closed as it isn't an actual bug just something with editors. Yeah?

@howeyc howeyc closed this as completed Aug 11, 2012
actgardner pushed a commit to scalingdata/fsnotify that referenced this issue Apr 2, 2015
actgardner pushed a commit to scalingdata/fsnotify that referenced this issue Apr 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants