vshRunConsole() uses virCondWait() which is a wrapper around
pthread_cond_wait(). On FreeBSD, pthread_cond_wait needs mutex to be
locked, otherwise it immediately fails with EPERM. On Linux, the
behaviour in this case is undefined.
So lock the mutex before calling virCondWait().
if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0)
goto cleanup;
+ virMutexLock(&con->lock);
+
con->stdinWatch = virEventAddHandle(STDIN_FILENO,
VIR_EVENT_HANDLE_READABLE,
virConsoleEventOnStdin,
while (!con->quit) {
if (virCondWait(&con->cond, &con->lock) < 0) {
+ virMutexUnlock(&con->lock);
VIR_ERROR(_("unable to wait on console condition"));
goto cleanup;
}
}
+ virMutexUnlock(&con->lock);
+
ret = 0;
cleanup: