Page MenuHomeFreeBSD

script: Handle terminal resize on SIGSWINCH
AcceptedPublic

Authored by xavier.beaudouin_klarasystems.com on Mar 1 2024, 3:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 11:16 AM
Unknown Object (File)
Fri, Nov 29, 11:16 AM
Unknown Object (File)
Fri, Nov 29, 11:16 AM
Unknown Object (File)
Fri, Nov 15, 8:44 PM
Unknown Object (File)
Tue, Nov 12, 12:02 AM
Unknown Object (File)
Mon, Nov 11, 3:58 PM
Unknown Object (File)
Sun, Nov 10, 9:21 PM
Unknown Object (File)
Sun, Nov 10, 9:21 PM

Details

Reviewers
des
sjg
Group Reviewers
Klara
Summary

Added '-w' to enable forwarding of these events follows.
Used checkstyle9.pl to fix also some style in this code.

Sponsored by: Modirum MDPay
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 56449
Build 53337: arc lint + arc unit

Event Timeline

allanjude retitled this revision from Handle terminal resize on SIGSWINCH in /usr/bin/script Added '-w' to enable forwarding of these events follows. to Handle terminal resize on SIGSWINCH in /usr/bin/scriptAdded '-w' to enable forwarding of these events follows..Mar 1 2024, 3:49 PM
allanjude added reviewers: Klara, des, sjg.
kevans added inline comments.
usr.bin/script/script.c
79

Prevailing style in this file seems to be to dropping the explicit initialization, it'll be in .bss anyways

97

Consistency again- drop the name of the parameter

115

This should probably go up with win and whatnot, to maintain some semblance of the current size-descending -ish ordering

309

I'm wondering if there's a way for this to fail; might be better to error-check it, just to avoid TIOCWINSZ with a potentially bogus win? It may not hae actually been initialized earlier if stdin isn't a tty, though I wonder now if you can hit that scenario *and* get a SIGWINCH somewhere in there.

Not suggesting doing anything with the error, just only doing the TIOCSWINSZ call if this one returned != -1

xavier.beaudouin_klarasystems.com retitled this revision from Handle terminal resize on SIGSWINCH in /usr/bin/scriptAdded '-w' to enable forwarding of these events follows. to Handle terminal resize on SIGSWINCH in /usr/bin/script Added '-w' to enable forwarding of these events follows..Mar 4 2024, 4:02 PM

Do initialization of variables in main().
Renamed the fuction onsigwinch() into resizeit().
Check if return -1 before doing the next ioctl.

usr.bin/script/script.c
309
usr.bin/script/script.c
97

You marked this as done but didn't actually do it.

112

Should be wflg for consistency.

116–117
171
274
311

This needs to be unconditional, otherwise you'll keep trying (and presumably failing) every time select() fires.

xavier.beaudouin_klarasystems.com marked 4 inline comments as done.

Variable names consitency.
Move do_resize=0 out of the if to avoid trying resize. May fail one time instead of always.

xavier.beaudouin_klarasystems.com added inline comments.
usr.bin/script/script.c
97

Right... Sorry

xavier.beaudouin_klarasystems.com retitled this revision from Handle terminal resize on SIGSWINCH in /usr/bin/script Added '-w' to enable forwarding of these events follows. to script: Handle terminal resize on SIGSWINCH.Mar 5 2024, 1:48 PM
xavier.beaudouin_klarasystems.com edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Mar 5 2024, 1:51 PM
usr.bin/script/script.c
127

These still needed? The comment is lame anyway... no version, no reason, no deeper explanation.... I know you're just fixing the style, but did you try it w/o the init? It's likely for gcc 4 at this point.

288
doresize) right?

Or do window changes not fire select?

308

is a 1 second latency sufficient? See above...

usr.bin/script/script.c
288

I don't believe they do; in the common case you're probably inside select(2) and you get smacked with an EINTR after returning from the signal handler.

You could perhaps block SIGWINCH and then switch to pselect(2) to unblock it and reliably interrupt it.

usr.bin/script/script.c
127

I don't know, is there any architecture supported by FreeBSD that use gcc for building ? (sorry for the stupid question indeed).