summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-10-03 12:23:39 +0300
committerSergey Bugaev <bugaevc@gmail.com>2019-10-03 12:23:39 +0300
commitc983120cc99a14e4e093445970af7a9c41a83468 (patch)
treec06cb2b02629301e0c8d1308595b619b85efacc6
parentcef29eac68d00e2c5e3d35c4f23804de24e15642 (diff)
Make sure to clean up the temp file on server communicaiton errors
-rw-r--r--src/wl-copy.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/wl-copy.c b/src/wl-copy.c
index e474e94..5f1766a 100644
--- a/src/wl-copy.c
+++ b/src/wl-copy.c
@@ -65,7 +65,7 @@ static void did_set_selection_callback(struct copy_action *copy_action) {
}
}
-static void cleanup_and_exit(struct copy_action *copy_action) {
+static void cleanup_and_exit(struct copy_action *copy_action, int code) {
/* We're done copying!
* All that's left to do now is to
* clean up after ourselves and exit.*/
@@ -76,17 +76,17 @@ static void cleanup_and_exit(struct copy_action *copy_action) {
perror("exec rm");
exit(1);
} else {
- exit(0);
+ exit(code);
}
}
static void cancelled_callback(struct copy_action *copy_action) {
- cleanup_and_exit(copy_action);
+ cleanup_and_exit(copy_action, 0);
}
static void pasted_callback(struct copy_action *copy_action) {
if (options.paste_once) {
- cleanup_and_exit(copy_action);
+ cleanup_and_exit(copy_action, 0);
}
}
@@ -275,5 +275,6 @@ int main(int argc, argv_t argv) {
while (wl_display_dispatch(wl_display) >= 0);
perror("wl_display_dispatch");
+ cleanup_and_exit(copy_action, 1);
return 1;
}