Revision a11d070e vl.c
b/vl.c | ||
---|---|---|
2050 | 2050 |
} |
2051 | 2051 |
} |
2052 | 2052 |
|
2053 |
static void fd_chr_close(struct CharDriverState *chr) |
|
2054 |
{ |
|
2055 |
FDCharDriver *s = chr->opaque; |
|
2056 |
|
|
2057 |
if (s->fd_in >= 0) { |
|
2058 |
if (nographic && s->fd_in == 0) { |
|
2059 |
} else { |
|
2060 |
qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL); |
|
2061 |
} |
|
2062 |
} |
|
2063 |
|
|
2064 |
qemu_free(s); |
|
2065 |
} |
|
2066 |
|
|
2053 | 2067 |
/* open a character device to a unix fd */ |
2054 | 2068 |
static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) |
2055 | 2069 |
{ |
... | ... | |
2069 | 2083 |
chr->opaque = s; |
2070 | 2084 |
chr->chr_write = fd_chr_write; |
2071 | 2085 |
chr->chr_update_read_handler = fd_chr_update_read_handler; |
2086 |
chr->chr_close = fd_chr_close; |
|
2072 | 2087 |
|
2073 | 2088 |
qemu_chr_reset(chr); |
2074 | 2089 |
|
... | ... | |
2155 | 2170 |
/* init terminal so that we can grab keys */ |
2156 | 2171 |
static struct termios oldtty; |
2157 | 2172 |
static int old_fd0_flags; |
2173 |
static int term_atexit_done; |
|
2158 | 2174 |
|
2159 | 2175 |
static void term_exit(void) |
2160 | 2176 |
{ |
... | ... | |
2184 | 2200 |
|
2185 | 2201 |
tcsetattr (0, TCSANOW, &tty); |
2186 | 2202 |
|
2187 |
atexit(term_exit); |
|
2203 |
if (!term_atexit_done++) |
|
2204 |
atexit(term_exit); |
|
2188 | 2205 |
|
2189 | 2206 |
fcntl(0, F_SETFL, O_NONBLOCK); |
2190 | 2207 |
} |
2191 | 2208 |
|
2209 |
static void qemu_chr_close_stdio(struct CharDriverState *chr) |
|
2210 |
{ |
|
2211 |
term_exit(); |
|
2212 |
stdio_nb_clients--; |
|
2213 |
qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); |
|
2214 |
fd_chr_close(chr); |
|
2215 |
} |
|
2216 |
|
|
2192 | 2217 |
static CharDriverState *qemu_chr_open_stdio(void) |
2193 | 2218 |
{ |
2194 | 2219 |
CharDriverState *chr; |
... | ... | |
2196 | 2221 |
if (stdio_nb_clients >= STDIO_MAX_CLIENTS) |
2197 | 2222 |
return NULL; |
2198 | 2223 |
chr = qemu_chr_open_fd(0, 1); |
2224 |
chr->chr_close = qemu_chr_close_stdio; |
|
2199 | 2225 |
qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); |
2200 | 2226 |
stdio_nb_clients++; |
2201 | 2227 |
term_init(); |
... | ... | |
3418 | 3444 |
{ |
3419 | 3445 |
if (chr->chr_close) |
3420 | 3446 |
chr->chr_close(chr); |
3447 |
qemu_free(chr); |
|
3421 | 3448 |
} |
3422 | 3449 |
|
3423 | 3450 |
/***********************************************************/ |
Also available in: Unified diff