|
@@ -301,6 +301,9 @@ static int qio_channel_command_close(QIOChannel *ioc,
|
|
{
|
|
{
|
|
QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
|
|
QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
|
|
int rv = 0;
|
|
int rv = 0;
|
|
|
|
+#ifndef WIN32
|
|
|
|
+ pid_t wp;
|
|
|
|
+#endif
|
|
|
|
|
|
/* We close FDs before killing, because that
|
|
/* We close FDs before killing, because that
|
|
* gives a better chance of clean shutdown
|
|
* gives a better chance of clean shutdown
|
|
@@ -315,11 +318,18 @@ static int qio_channel_command_close(QIOChannel *ioc,
|
|
rv = -1;
|
|
rv = -1;
|
|
}
|
|
}
|
|
cioc->writefd = cioc->readfd = -1;
|
|
cioc->writefd = cioc->readfd = -1;
|
|
|
|
+
|
|
#ifndef WIN32
|
|
#ifndef WIN32
|
|
- if (qio_channel_command_abort(cioc, errp) < 0) {
|
|
|
|
|
|
+ do {
|
|
|
|
+ wp = waitpid(cioc->pid, NULL, 0);
|
|
|
|
+ } while (wp == (pid_t)-1 && errno == EINTR);
|
|
|
|
+ if (wp == (pid_t)-1) {
|
|
|
|
+ error_setg_errno(errp, errno, "Failed to wait for pid %llu",
|
|
|
|
+ (unsigned long long)cioc->pid);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
if (rv < 0) {
|
|
if (rv < 0) {
|
|
error_setg_errno(errp, errno, "%s",
|
|
error_setg_errno(errp, errno, "%s",
|
|
"Unable to close command");
|
|
"Unable to close command");
|