From 8da7c7af60a63ab0dfdb45e8d8c5f1080d87e5e8 Mon Sep 17 00:00:00 2001 From: Rusty Bird Date: Wed, 25 Jul 2018 12:44:52 +0000 Subject: [PATCH] qfile-agent.c: exit on EPIPE after gui progress write The qvm-{copy,move}-to-vm.{gnome,kde} cancel buttons didn't actually cancel, because qfile-agent ignored EPIPE and - via qfile_pack_init() - SIGPIPE. So it never noticed when the local PROGRESS_TYPE=gui reader had shut down. --- qubes-rpc/qfile-agent.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qubes-rpc/qfile-agent.c b/qubes-rpc/qfile-agent.c index 42a1dfd..2ea9733 100644 --- a/qubes-rpc/qfile-agent.c +++ b/qubes-rpc/qfile-agent.c @@ -33,15 +33,16 @@ void do_notify_progress(long long total, int flag) ignore = write(2, msg, strlen(msg)); if (flag == PROGRESS_FLAG_DONE) ignore = write(2, "\n", 1); + if (ignore < 0) { + /* silence gcc warning */ + } } if (!strcmp(progress_type_env, "gui") && saved_stdout_env) { char msg[256]; snprintf(msg, sizeof(msg), "%lld\n", total); - ignore = write(strtoul(saved_stdout_env, NULL, 0), msg, - strlen(msg)); - } - if (ignore < 0) { - /* silence gcc warning */ + if (write(strtoul(saved_stdout_env, NULL, 0), msg, strlen(msg)) == -1 + && errno == EPIPE) + exit(32); } }