diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-12-21 12:40:53 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-12-21 12:40:53 +0000 |
| commit | e4ae5a7586cce0ee4efa7f264404dff49f70e87e (patch) | |
| tree | 2cdf41bddb29705fc1d769d2ae4b5760b0271240 | |
| parent | install: remove -march=native (diff) | |
generate-alt-random: ioctl(TIOCGWINSZ) may fail in run inside a container
This _should_ only happen when we’re doing a partial PGO build, since
then the script is run in the parent terminal. In this case, the user
is expected to use --rows/--cols anyway.
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rwxr-xr-x | scripts/generate-alt-random-writes.py | 19 |
2 files changed, 18 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c37f0639..4f9ca3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,10 @@ ### Deprecated ### Removed ### Fixed + +* `generate-alt-random.py` failing in containers. + + ### Security ### Contributors diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 202c99c5..2e51082b 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -37,11 +37,17 @@ def main(): opts = parser.parse_args() out = opts.out if opts.out is not None else sys.stdout - lines, cols, height, width = struct.unpack( - 'HHHH', - fcntl.ioctl(sys.stdout.fileno(), - termios.TIOCGWINSZ, - struct.pack('HHHH', 0, 0, 0, 0))) + try: + lines, cols, height, width = struct.unpack( + 'HHHH', + fcntl.ioctl(sys.stdout.fileno(), + termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) + except OSError: + lines = None + cols = None + height = None + width = None if opts.rows is not None: lines = opts.rows @@ -50,6 +56,9 @@ def main(): cols = opts.cols width = 8 * cols # PGO help binary hardcodes cell width to 8px + if lines is None or cols is None or height is None or width is None: + raise Exception('could not get terminal width/height; use --rows and --cols') + # Number of characters to write to screen count = 256 * 1024**1 |
