Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit ed35e73

Browse files
committed
Merge branch '4630_resize'
* 4630_resize: (toggle_subshell): fix possible race condition on SIGWINCH handling. (tty_flush_winch): return boolean. Ticket #4630: mc doesn't fully resize itself...
2 parents e7e2186 + c0c9575 commit ed35e73

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

lib/tty/tty.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ tty_got_winch (void)
216216

217217
/* --------------------------------------------------------------------------------------------- */
218218

219-
void
219+
gboolean
220220
tty_flush_winch (void)
221221
{
222222
ssize_t n;
223+
gboolean ret = FALSE;
223224

224225
/* merge all SIGWINCH events raised to this moment */
225226
do
@@ -228,8 +229,14 @@ tty_flush_winch (void)
228229

229230
/* read multiple events at a time */
230231
n = read (sigwinch_pipe[0], &x, sizeof (x));
232+
233+
/* at least one SIGWINCH came */
234+
if (n > 0)
235+
ret = TRUE;
231236
}
232237
while (n > 0 || (n == -1 && errno == EINTR));
238+
239+
return ret;
233240
}
234241

235242
/* --------------------------------------------------------------------------------------------- */

lib/tty/tty.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extern void tty_disable_interrupt_key (void);
8181
extern gboolean tty_got_interrupt (void);
8282

8383
extern gboolean tty_got_winch (void);
84-
extern void tty_flush_winch (void);
84+
extern gboolean tty_flush_winch (void);
8585

8686
extern void tty_reset_prog_mode (void);
8787
extern void tty_reset_shell_mode (void);

lib/widget/dialog-switch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ dialog_change_screen_size (void)
386386
{
387387
GList *d;
388388

389+
/* On startup, when mc reads directories top_dlg isn't created yet. If window is resized
390+
* at this time, SIGWINCH can be missed because tty_flush_winch() is called here before
391+
* a first tty_got_winch() call in frontend_dlg_run().
392+
*
393+
* Keep SIGWINCH events in pipe if top_dlg isn't created yet. */
394+
if (top_dlg == NULL)
395+
return;
396+
389397
tty_flush_winch ();
390398
tty_change_screen_size ();
391399

src/execute.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ toggle_subshell (void)
547547
* Save sigwinch flag that will be reset in mc_refresh() called via update_panels().
548548
* There is some problem with screen redraw in ncurses-based mc in this situation.
549549
*/
550-
was_sigwinch = tty_got_winch ();
551-
tty_flush_winch ();
550+
was_sigwinch = tty_flush_winch ();
552551

553552
#ifdef ENABLE_SUBSHELL
554553
if (mc_global.tty.use_subshell)

0 commit comments

Comments
 (0)