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  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Confirmed
Privacy: PublicAssigned to: None
Open/Closed: OpenRelease: None

Add a New Comment (Rich MarkupRich 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 Member
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 Member
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 Member
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 File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 28 Jun 2015 07:21:21 AM UTCbensStatusNone=>Confirmed
    Wed 24 Mar 2010 09:51:57 AM UTCsayapCarbon-Copy-=>Added sayap

    Back to the top

    Powered by Savane 3.1-cleanup