aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-09-23 23:01:30 +0200
committerPřemysl Janouch <p@janouch.name>2019-09-23 23:07:04 +0200
commit90b5364b29a65d141b7f260a2be5ece5db140b36 (patch)
tree7c00291aee7775a3c9a346ec50a6cf6e74944406
parent1840ac795eb9d95f99dcad782ac2c4f88b625aee (diff)
downloadjson-rpc-shell-90b5364b29a65d141b7f260a2be5ece5db140b36.tar.gz
json-rpc-shell-90b5364b29a65d141b7f260a2be5ece5db140b36.tar.xz
json-rpc-shell-90b5364b29a65d141b7f260a2be5ece5db140b36.zip
Fix running helper programs
A bug was introduced in 5c38087.
-rw-r--r--json-rpc-shell.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 47ef3b8..e8bf9fb 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -3184,8 +3184,6 @@ process_edited_input (struct app_context *ctx)
print_error ("could not unlink `%s': %s",
ctx->editor_filename, strerror (errno));
- free (ctx->editor_filename);
- ctx->editor_filename = NULL;
str_free (&input);
}
@@ -3203,7 +3201,7 @@ on_child (EV_P_ ev_child *handle, int revents)
kill (-handle->rpid, SIGKILL);
return;
}
- // I don't recognize this child (we should also check PID)
+ // I don't recognize this child (we should also check its PID)
if (!ctx->editor_filename)
return;
@@ -3216,6 +3214,9 @@ on_child (EV_P_ ev_child *handle, int revents)
print_error ("editor returned status %d", WEXITSTATUS (status));
else
process_edited_input (ctx);
+
+ free (ctx->editor_filename);
+ ctx->editor_filename = NULL;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -3250,8 +3251,14 @@ on_tty_readable (EV_P_ ev_io *handle, int revents)
{
// rl_callback_read_char() is not reentrant, may happen on EOF
ev_io_stop (EV_DEFAULT_ &ctx->tty_watcher);
+
ctx->input->vtable->on_tty_readable (ctx->input);
- ev_io_start (EV_DEFAULT_ &ctx->tty_watcher);
+
+ // Don't make ourselves receive a SIGTTIN. Ideally we'd prevent
+ // reentrancy without inciting conflicts with
+ // {suspend,resume}_terminal() but I can't figure anything out.
+ if (!ctx->editor_filename)
+ ev_io_start (EV_DEFAULT_ &ctx->tty_watcher);
}
}