Skip to content

FS notification stop after using sed command on the file #143

Closed

Description

@prateekgogia

HI

If I manually edit the file watched, I get the notifications. However, if I try to edit a file using sed command. I don't receive any notification for this or any subsequent notifications even if I update the file manually with VIM after using sed command.
This is the sed command I am using:

sed -i 's,'getLatestImage=true','getLatestImage=false','

I added some logs and looks like after using this sed command, we are always waiting on this call:
n, errno := syscall.EpollWait(poller.epfd, events, -1) in inotify_poller.go

I don't see any response from this call after using sed command, even when I change the file manually using VIM.

Thanks

Activity

  1. nathany commented on May 4, 2016

    @nathany
    Contributor

    Thanks for the report. Which operating system is this on?

  2. suihkulokki commented on May 9, 2016

    @suihkulokki
    Contributor

    "sed -i foo" is a bit misleading, it doesn't really edit the file in-place - it outputs the file to a temporary file and renames:

    open("foo", O_RDONLY)
    open("./sedkYoTpL", O_RDWR|O_CREAT)
    rename("./sedkYoTpL", "foo")

    So the original file inotify is watching no longer exists and the new file isn't monitored. I think you need to watch the directory if you want to catch changes like this.

  3. nathany commented on May 10, 2016

    @nathany
    Contributor

    Thanks @suihkulokki. So sed exhibits the same issues as text editors #17.

  4. arp242 commented on Jul 21, 2022

    @arp242
    Member

    The general way to deal with this is to watch the parent directory and then filter on the file path. It's annoying :-/ There are some other scenarios where this happens to, such as compilers generating binaries.

    Either way, seems a duplicate of #17, so I'll close it as such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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