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.
This commit is contained in:
Rusty Bird 2018-07-25 12:44:52 +00:00
parent f037ffa852
commit 8da7c7af60
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF

View File

@ -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);
}
}