fix wait routine in bochs for linux

This commit is contained in:
skuater 2016-04-03 04:54:14 +02:00 committed by pancake
parent 9eb63df89f
commit 36edff3732
2 changed files with 10 additions and 9 deletions

View File

@ -27,7 +27,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) {
if (!__plugin_open (io, file, 0)) {
return NULL;
}
if (!r_sandbox_enable (false)) {
if (r_sandbox_enable (false)) {
eprintf ("sandbox exit\n");
return NULL;
}

View File

@ -94,14 +94,15 @@ bool bochs_wait(libbochs_t *b) {
n = fcntl (b->hReadPipeIn, (flags | O_NONBLOCK));
while (1) {
n = read (b->hReadPipeIn, lpTmpBuffer, SIZE_BUF - 1);
if (n < 1) break;
lpTmpBuffer[n] = 0;
if (b->punteroBuffer + n >= SIZE_BUF - 1)
bochs_reset_buffer(b);
memcpy (&b->data[b->punteroBuffer], lpTmpBuffer, n + 1);
b->punteroBuffer += n;
if (strstr (&b->data[0], "<bochs:")) {
break;
if (n >0) {
lpTmpBuffer[n] = 0;
if (b->punteroBuffer + n >= SIZE_BUF - 1)
bochs_reset_buffer(b);
memcpy (&b->data[b->punteroBuffer], lpTmpBuffer, n + 1);
b->punteroBuffer += n;
if (strstr (&b->data[0], "<bochs:")) {
break;
}
}
}
n = fcntl (b->hReadPipeIn, (flags | ~O_NONBLOCK));