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
1 changed files with 12 additions and 4 deletions

View File

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