--- linux-user/main.c 2005-05-04 13:38:41.942234771 +0300 +++ linux-user/main.c 2005-05-04 10:44:52.851592991 +0300 @@ -25,4 +25,7 @@ #include #include "qemu.h" +#include "exec-all.h" + +int flush_close; @@ -467,6 +470,12 @@ abort(); } process_pending_signals(env); + + if (flush_close) + { + tb_flush(env); + flush_close = 0; + } } } @@ -1150,6 +1159,8 @@ if (argc <= 1) usage(); + flush_close = 0; + /* init debug */ cpu_set_log_filename(DEBUG_LOGFILE); --- linux-user/qemu.h 2005-05-04 13:38:41.894241261 +0300 +++ linux-user/qemu.h 2005-05-04 10:44:52.838594744 +0300 @@ -15,4 +15,6 @@ +extern int flush_close; + /* This struct is used to hold certain information about the image. * Basically, it replicates in user space what would be certain * task_struct fields in the kernel --- linux-user/syscall.c 2005-05-04 13:38:41.953233283 +0300 +++ linux-user/syscall.c 2005-05-04 12:59:27.226329045 +0300 @@ -1721,7 +1721,24 @@ arg3)); break; case TARGET_NR_close: + { + struct stat buf; + + ret = fstat(arg1, &buf); + + if ((ret == 0) && (S_ISREG(buf.st_mode)) && (buf.st_mode & S_IRUSR)) + { + char str[EI_PAD]; + + if (lseek(arg1, 0, SEEK_SET) != (off_t)-1) + if (read(arg1, str, EI_PAD) > 0) + if (str[EI_MAG0] == ELFMAG0 && str[EI_MAG1] == ELFMAG1 && + str[EI_MAG1] == ELFMAG1 && str[EI_MAG3] == ELFMAG3) + flush_close = 1; + } + ret = get_errno(close(arg1)); + } break; case TARGET_NR_brk: ret = do_brk((char *)arg1);