Revision 7d7d975c

b/cmd.c
24 24
#include <getopt.h>
25 25

  
26 26
#include "cmd.h"
27
#include "qemu-aio.h"
27 28

  
28 29
#define _(x)	x	/* not gettext support yet */
29 30

  
......
149 150
	args_func = af;
150 151
}
151 152

  
153
static void prep_fetchline(void *opaque)
154
{
155
    int *fetchable = opaque;
156

  
157
    qemu_aio_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL, NULL, NULL);
158
    *fetchable= 1;
159
}
160

  
161
static char *get_prompt(void);
162

  
152 163
void
153 164
command_loop(void)
154 165
{
155
	int		c, i, j = 0, done = 0;
166
	int		c, i, j = 0, done = 0, fetchable = 0, prompted = 0;
156 167
	char		*input;
157 168
	char		**v;
158 169
	const cmdinfo_t	*ct;
......
186 197
		free(cmdline);
187 198
		return;
188 199
	}
200

  
189 201
	while (!done) {
202
        if (!prompted) {
203
            printf("%s", get_prompt());
204
            fflush(stdout);
205
            qemu_aio_set_fd_handler(STDIN_FILENO, prep_fetchline, NULL, NULL,
206
                                    NULL, &fetchable);
207
            prompted = 1;
208
        }
209

  
210
        qemu_aio_wait();
211

  
212
        if (!fetchable) {
213
            continue;
214
        }
190 215
		if ((input = fetchline()) == NULL)
191 216
			break;
192 217
		v = breakline(input, &c);
......
199 224
					v[0]);
200 225
		}
201 226
		doneline(input, v);
227

  
228
        prompted = 0;
229
        fetchable = 0;
202 230
	}
231
    qemu_aio_set_fd_handler(STDIN_FILENO, NULL, NULL, NULL, NULL, NULL);
203 232
}
204 233

  
205 234
/* from libxcmd/input.c */
......
270 299

  
271 300
	if (!line)
272 301
		return NULL;
273
	printf("%s", get_prompt());
274
	fflush(stdout);
275 302
	if (!fgets(line, MAXREADLINESZ, stdin)) {
276 303
		free(line);
277 304
		return NULL;

Also available in: Unified diff