all repos — xyw @ 169554aaf19b03543691d23092dd209fefb53d08

A minimal virtual machine and assembler for terminals.

Preventing terminal corruption on linux.
h3rald h3rald@h3rald.com
Tue, 28 Jul 2026 13:35:10 +0200
commit

169554aaf19b03543691d23092dd209fefb53d08

parent

d9ad522501e01ea2cf3b33748fc2cae52d09e9e5

2 files changed, 10 insertions(+), 1 deletions(-)

jump to
M test.shtest.sh

@@ -99,7 +99,7 @@

need_file "$EXAMPLES_DIR/$img_basename" local run_log="$TMPDIR/run.${img_basename}.log" - if ! (cd "$EXAMPLES_DIR" && "$xyw_bin" "$img_basename" "${run_args[@]}" >"$out_file" 2>"$run_log"); then + if ! (cd "$EXAMPLES_DIR" && "$xyw_bin" "$img_basename" "${run_args[@]}" </dev/null >"$out_file" 2>"$run_log"); then dump_file_if_exists "Runtime stderr" "$run_log" dump_file_if_exists "Runtime stdout" "$out_file" fail "Execution failed for $img_basename"
M xywrun.cxywrun.c

@@ -1,6 +1,7 @@

#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include "xyw.h" #include "devices/system.h"

@@ -660,6 +661,12 @@ *yw = saved_yw;

return xyw_memory[SYSTEM_ERROR]; } +static void xyw_signal_exit(int sig) +{ + (void)sig; + exit(1); +} + static void xyw_teardown_devices(void) { for (int i = 0; i < XYW_TOTAL_DEVICES; i++)

@@ -675,6 +682,8 @@ //// Main run function

int xyw_run(const char *input) { atexit(xyw_teardown_devices); + signal(SIGINT, xyw_signal_exit); + signal(SIGTERM, xyw_signal_exit); if (xyw_vm_load_image(input, NULL) != 0) {