bugGNU nano - Bugs: bug #56038, nano stops reading from external...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #56038: nano stops reading from external command when window is resized

Submitter:  Brand Huntsman <brand>
Submitted:  Sun 31 Mar 2019 01:30:07 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Tue 16 Apr 2019 08:46:26 AM UTC, comment #9: 

The fix has been released in 4.1.  Thanks for reporting.

Benno Schulenberg <bens>
Group administrator
Wed 03 Apr 2019 01:18:55 PM UTC, comment #8: 

Fixed in git, commit 32431cdd.

Benno Schulenberg <bens>
Group administrator
Wed 03 Apr 2019 12:15:59 PM UTC, comment #7: 

Just for testing, I've put a napms(1500) before the sigwinch block and after the unblock, and I resize the terminal the whole time while the command is executing, but I can't make it misbehave.  So I guess that, as you say, the chances of causing a SIGWINCH at an incovenient time are now exceedingly small.  So I think the patch as it now is is good enough.

Benno Schulenberg <bens>
Group administrator
Tue 02 Apr 2019 09:25:39 PM UTC, comment #6: 

Since reading a file doesn't abort (thanks for testing), it means the child process is aborting, not the getc(). If the SIGWINCH happens any time after the unblock in read_file(), the child process could abort and the waits will display their error messages. But if the SIGWINCH happens before the block in read_file() it could abort the child process before any data has been sent. So the block should probably wrap the entire lifetime of the child process, complicating the blocking inside read_file() with a conditional global or function parameter.

However, the chance of resizing before or after the read_file() blocks should be almost impossible. And the blocks around waits are useless without a block before them, so I'm fine with your changes.

But I'm not entirely sure about the reliability of regenerating the screen inside block_sigwinch(). It will fail if sigprocmask() is not guaranteed to always immediately process the signal. But the regenerating could NOT be done inside block_sigwinch() if we do block for the entire duration of the child process, because it would erase the statusbar message. It wouldn't be hard to restore the statusbar message, I did it before but can't find the code.

Should I add a full block for duration of child process? Should I  write a separate patch to restore statusbar in total_refresh() and not regenerate screen in block_sigwinch()?

Brand Huntsman <brand>
Tue 02 Apr 2019 05:56:06 PM UTC, comment #5: 

With the sigwinch blocks in read_file(), the blocks around the wait()s appear to no longer be needed.  When removing them from the patch, I cannot find any misbehavior.  Okay to remove?

Reading a large file (without the patch) does not get aborted by sigwinches.  It's just that afterwards the screen is not resized properly and the first keystroke is eaten.  Your patch avoids those things too.

Benno Schulenberg <bens>
Group administrator
Sun 31 Mar 2019 11:54:29 PM UTC, comment #4: 

I moved blocking inside read_file() because resizing while reading from a file would probably also abort.

regenerate_screen() clears the "Read N lines" statusbar message that read_file() displays. I added it to block_sigwinch() and sigprocmask() seems to immediately invoke the SIGWINCH handler, refreshing the screen before read_file() displays its message.

It would be better if statusline() stored the current message, wipe_statusbar() cleared it and total_refresh() displayed a stored message instead of wiping it.

(file #46683)

Brand Huntsman <brand>
Sun 31 Mar 2019 08:00:15 PM UTC, comment #3: 

There is a second wait below it and a read_file above it. Moving the blocks to encompass all three fixes it but the terminal doesn't update until a key is pressed, and that key doesn't enter buffer...

Brand Huntsman <brand>
Sun 31 Mar 2019 06:58:02 PM UTC, comment #2: 

The patch doesn't fix the issue.  When resizing the window, the statusbar immediately shows "Read 2 lines" or such.  But then, strangely, it takes about half a second before the buffer contents are actually shown.  What wait is happening there?  And why is the blocking not having any effect?

Benno Schulenberg <bens>
Group administrator
Sun 31 Mar 2019 06:52:24 PM UTC, comment #1: 

A more visual reproduction recipe is: run 'nano --ignore' and type:

  ^R^X for name in conf*; do echo $name; sleep 2; done <Enter>

Then resize the window.  Only a few filenames will have been entered into the buffer, instead of all nine or ten.

Benno Schulenberg <bens>
Group administrator
Sun 31 Mar 2019 01:30:07 AM UTC, original submission:  

Execute the "sleep 30" command and then resize nano. It closes the prompt and leaves the command running in the background. Any remaining output from a real program would not be added to the buffer. And some programs will become a zombie process until nano is terminated.

Wrapping the wait() in text.c execute_command() with block_sigwinch() calls fixes the issue. That function first needs to be made available if not NANO_TINY.

Brand Huntsman <brand>

 

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

 

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 brand (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-16 bens Open/ClosedOpen Closed
    2019-04-03 bens StatusIn Progress Fixed
    2019-04-02 bens Attached File- Added 0001-files-block-the-resizing-signal-while-reading-from-a.patch, #46699
    2019-03-31 brand Attached File- Added 0001-block-SIGWINCHes-while-executing-a-command.patch, #46683
    2019-03-31 bens Summarynano stops reading from executing command when window is resized nano stops reading from external command when window is resized
    2019-03-31 bens StatusNone In Progress
        Assigned toNone bens
    2019-03-31 brand Attached File- Added 0001-block-SIGWINCHes-while-executing-a-command.patch, #46677

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code