aboutsummaryrefslogtreecommitdiff
path: root/io/channel-command.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-02-16 11:19:37 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-02-16 11:19:37 +0000
commit0402ca3c70356e09e694fece39256790ff7755f2 (patch)
treee60eaec9d9f13e2b70a4704e58ebf23378211888 /io/channel-command.c
parent5e5432b766c424a5d1e1b81315ce6ac1dc0fa3ed (diff)
parent6809df1df036840d41a0cc9ca77cc6a0214fb1b5 (diff)
Merge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging
# gpg: Signature made Thu 15 Feb 2018 17:50:22 GMT # gpg: using RSA key BE86EBB415104FDF # gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" # gpg: aka "Daniel P. Berrange <berrange@redhat.com>" # Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF * remotes/berrange/tags/qio-next-pull-request: allow to build with older sed io/channel-command: Do not kill the child process after closing the pipe io: Add /dev/fdset/ support to QIOChannelFile io: Don't call close multiple times in QIOChannelFile io: Fix QIOChannelFile when creating and opening read-write io/channel-websock: handle continuous reads without any data io: fix QIONetListener memory leak Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'io/channel-command.c')
-rw-r--r--io/channel-command.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/io/channel-command.c b/io/channel-command.c
index 319c5ed50c..3e7eb17eff 100644
--- a/io/channel-command.c
+++ b/io/channel-command.c
@@ -301,6 +301,9 @@ static int qio_channel_command_close(QIOChannel *ioc,
{
QIOChannelCommand *cioc = QIO_CHANNEL_COMMAND(ioc);
int rv = 0;
+#ifndef WIN32
+ pid_t wp;
+#endif
/* We close FDs before killing, because that
* gives a better chance of clean shutdown
@@ -315,11 +318,18 @@ static int qio_channel_command_close(QIOChannel *ioc,
rv = -1;
}
cioc->writefd = cioc->readfd = -1;
+
#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;
}
#endif
+
if (rv < 0) {
error_setg_errno(errp, errno, "%s",
"Unable to close command");