On 16/12/2015 17:56, Alex Pyrgiotis wrote: > + > + log = qemu_get_log_filename(); > + if (log != NULL) { > + TFR(fd = qemu_open(log, O_RDWR | O_APPEND | O_CREAT, 0640));
Here you are opening the same file twice, but the FILE* that is opened in do_qemu_set_log does not necessarily have O_APPEND. I like the idea of moving stderr to the logfile, but I'm not sure how to do it. For now, can you prepare a simple patch that only does the "dup" if "isatty" returns true for the file descriptor? This lets you use redirection at the shell level to save the stdout and stderr. Paolo > + } else { > + TFR(fd = qemu_open("/dev/null", O_RDWR)); > + } > if (fd == -1) { > + fprintf(stderr, "Cannot open \"%s\" for logging\n", log); > exit(1); > } > + g_free(log); > }