u-boot/arch
Rasmus Villemoes 2960107a22 sandbox: also restore terminal settings when killed by SIGINT
Hitting Ctrl-C is a documented way to exit the sandbox, but it is not
actually equivalent to the reset command. The latter, since it follows
normal process exit, takes care to reset terminal settings and
restoring the O_NONBLOCK behaviour of stdin (and, in a terminal, that
is usually the same file description as stdout and stderr, i.e. some
/dev/pts/NN).

Failure to restore (remove) O_NONBLOCK from stdout/stderr can cause
very surprising and hard to debug problems back in the terminal. For
example, I had "make -j8" consistently failing without much
information about just exactly what went wrong, but sometimes I did
get a "echo: write error". I was at first afraid my disk was getting
bad, but then a simple "dmesg" _also_ failed with write error - so it
was writing to the terminal that was buggered. And both "make -j8" and
dmesg in another terminal window worked just fine.

So install a SIGINT handler so that if the chosen terminal
mode (cooked or raw-with-sigs) means Ctrl-C sends a SIGINT, we will
still call os_fd_restore(), then reraise the signal and die as usual
from SIGINT.

Before:

$ grep flags /proc/$$/fdinfo/1
flags:  0102002
$ ./u-boot
# hit Ctrl-C
$ grep flags /proc/$$/fdinfo/1
flags:  0106002

After:

$ grep flags /proc/$$/fdinfo/1
flags:  0102002
$ ./u-boot
# hit Ctrl-C
$ grep flags /proc/$$/fdinfo/1
flags:  0102002

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
2020-04-16 08:07:57 -06:00
..
arc kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
arm ARM: dts: stm32: Rename LEDs to match silkscreen on AV96 2020-04-15 09:09:21 +02:00
m68k kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
microblaze Kconfig: Remove redundant variable sets 2020-03-16 16:42:50 -04:00
mips Merge branch 'next' 2020-04-13 11:27:00 -04:00
nds32 dma-mapping: move dma_map_(un)single() to <linux/dma-mapping.h> 2020-02-19 21:27:30 +08:00
nios2 common: Move hang() to the same header as panic() 2020-01-24 23:06:49 +05:30
powerpc kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
riscv kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
sandbox sandbox: also restore terminal settings when killed by SIGINT 2020-04-16 08:07:57 -06:00
sh dma-mapping: add <asm/dma-mapping.h> for all architectures 2020-02-20 15:09:54 +08:00
x86 kconfig / kbuild: Re-sync with Linux 4.19 2020-04-10 11:18:32 -04:00
xtensa dma-mapping: add <asm/dma-mapping.h> for all architectures 2020-02-20 15:09:54 +08:00
.gitignore
Kconfig x86: Enable pinctrl in SPL and TPL 2019-12-15 11:44:24 +08:00
u-boot-elf.lds arch: Add explicit linker script for u-boot-elf 2020-04-03 11:52:55 -04:00