bugGNU nano - Bugs: bug #29312, nano triggers inotify CLOSE_WRITE...


bug #29312: nano triggers inotify CLOSE_WRITE event when opening a file

Submitted by:  None
Submitted on:  Tue 23 Mar 2010 07:07:04 AM UTC  
Severity:  3 - Normal Status:  Confirmed
Assigned to:  None Open/Closed:  Open

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 19 Jul 2015 03:56:53 PM UTC, comment #3:

The closing of the file after reading it is not the problem. The problem occurs in 'is_file_writable()', which opens the file for writing (just to check whether nano can write to it).

This feature was added in September 2009, shortly before version 2.1.11. However, vim nor emacs do this. For reporting that the file is not writable, they rely on just the permission bits. Chris? Why was this not enough for nano?

Benno Schulenberg <bens>
Project Administrator
Sun 28 Jun 2015 07:21:21 AM UTC, comment #2:

In a strace, nano first opens the given file, then opens and closes the nano.mo messages files for the current locale, and then closes the given file (and often it opens and closes the given file even a second time) before trying to determine its full path and before starting to edit.

Apparently it will be necessary to keep the file being edited open during the whole time that the associated buffer is open.

Benno Schulenberg <bens>
Project Administrator
Sun 28 Jun 2015 07:03:36 AM UTC, comment #1:

A simpler recipe (and one that avoids being triggered by the lock file being written and closed) is:

touch TOSSO
inotifywait -e close_write TOSSO

Then in another terminal:

nano TOSSO

Benno Schulenberg <bens>
Project Administrator
Tue 23 Mar 2010 07:07:04 AM UTC, original submission:

Firstly, create a temp folder and a test file

$ mkdir ~/temp
$ touch ~/temp/test.txt

Then, start inotifywait on another terminal

$ inotifywait -e close_write ~/temp

Open the test file with nano

$ nano ~/temp/test.txt

As soon as the file is opened, inotifywait will exit with this output:

/home/xxx/temp/ CLOSE_WRITE,CLOSE test.txt



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by sayap

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-28 bens StatusNone => Confirmed
    2010-03-24 sayap Carbon-Copy- => Added sayap

    Back to the top

    Powered by Savane 3.3