]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/sandbox/cpu/os.c
sandbox: Add options to clean up temporary files
[karo-tx-uboot.git] / arch / sandbox / cpu / os.c
index 52e1096f36ce18d66623db607acd7f8dfd03d79d..57d04a45b22b7edf813629bbff4bb7c6e5bef255 100644 (file)
@@ -104,21 +104,22 @@ void os_exit(int exit_code)
 
 /* Restore tty state when we exit */
 static struct termios orig_term;
+static bool term_setup;
 
 static void os_fd_restore(void)
 {
-       tcsetattr(0, TCSANOW, &orig_term);
+       if (term_setup)
+               tcsetattr(0, TCSANOW, &orig_term);
 }
 
 /* Put tty into raw mode so <tab> and <ctrl+c> work */
-void os_tty_raw(int fd)
+void os_tty_raw(int fd, bool allow_sigs)
 {
-       static int setup = 0;
        struct termios term;
 
-       if (setup)
+       if (term_setup)
                return;
-       setup = 1;
+       term_setup = true;
 
        /* If not a tty, don't complain */
        if (tcgetattr(fd, &orig_term))
@@ -128,7 +129,7 @@ void os_tty_raw(int fd)
        term.c_iflag = IGNBRK | IGNPAR;
        term.c_oflag = OPOST | ONLCR;
        term.c_cflag = CS8 | CREAD | CLOCAL;
-       term.c_lflag = 0;
+       term.c_lflag = allow_sigs ? ISIG : 0;
        if (tcsetattr(fd, TCSANOW, &term))
                return;
 
@@ -487,7 +488,7 @@ int os_jump_to_image(const void *dest, int size)
        struct sandbox_state *state = state_get_current();
        char fname[30], mem_fname[30];
        int fd, err;
-       const char *extra_args[4];
+       const char *extra_args[5];
        char **argv = state->argv;
 #ifdef DEBUG
        int argc, i;
@@ -512,6 +513,7 @@ int os_jump_to_image(const void *dest, int size)
        extra_args[1] = fname;
        extra_args[2] = "-m";
        extra_args[3] = mem_fname;
+       extra_args[4] = "--rm_memory";
        err = add_args(&argv, extra_args,
                       sizeof(extra_args) / sizeof(extra_args[0]));
        if (err)