degesch: fix handling of input editor death

This commit is contained in:
Přemysl Eric Janouch 2016-01-07 22:47:57 +01:00
parent cabab5f351
commit a5ac0d24b8

View File

@ -10871,7 +10871,7 @@ launch_input_editor (struct app_context *ctx)
} }
static void static void
process_edited_input (struct app_context *ctx) input_editor_process (struct app_context *ctx)
{ {
struct str input; struct str input;
str_init (&input); str_init (&input);
@ -10889,13 +10889,18 @@ process_edited_input (struct app_context *ctx)
log_global_error (ctx, "#s: #s", "Input editing failed", log_global_error (ctx, "#s: #s", "Input editing failed",
"could not re-insert the modified text"); "could not re-insert the modified text");
str_free (&input);
}
static void
input_editor_cleanup (struct app_context *ctx)
{
if (unlink (ctx->editor_filename)) if (unlink (ctx->editor_filename))
log_global_error (ctx, "Could not unlink `#s': #l", log_global_error (ctx, "Could not unlink `#s': #l",
ctx->editor_filename, strerror (errno)); ctx->editor_filename, strerror (errno));
free (ctx->editor_filename); free (ctx->editor_filename);
ctx->editor_filename = NULL; ctx->editor_filename = NULL;
str_free (&input);
ctx->running_editor = false; ctx->running_editor = false;
} }
@ -11628,7 +11633,7 @@ try_reap_child (struct app_context *ctx)
ctx->running_backlog_helper = false; ctx->running_backlog_helper = false;
else if (!ctx->running_editor) else if (!ctx->running_editor)
{ {
print_debug ("an unknown child has died"); log_global_debug (ctx, "An unknown child has died");
return true; return true;
} }
@ -11642,7 +11647,10 @@ try_reap_child (struct app_context *ctx)
log_global_error (ctx, log_global_error (ctx,
"Child returned status #d", WEXITSTATUS (status)); "Child returned status #d", WEXITSTATUS (status));
else if (ctx->running_editor) else if (ctx->running_editor)
process_edited_input (ctx); input_editor_process (ctx);
if (ctx->running_editor)
input_editor_cleanup (ctx);
return true; return true;
} }