aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event/pty_process.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-08-13 12:20:53 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-08-13 12:20:53 -0300
commita94a68145b3c607d1e58f708ded8fe625c9973d5 (patch)
tree2d69f4f3a06f0ac5a4e936ec40bde81a26cf2b53 /src/nvim/event/pty_process.c
parent6bf322c6ff190b9f10c5286b3ae6fceedfbddb61 (diff)
parentf1de097dbb236ea400150f80b909407ca9af7441 (diff)
downloadrneovim-a94a68145b3c607d1e58f708ded8fe625c9973d5.tar.gz
rneovim-a94a68145b3c607d1e58f708ded8fe625c9973d5.tar.bz2
rneovim-a94a68145b3c607d1e58f708ded8fe625c9973d5.zip
Merge PR #3029 'Refactor event processing architecture'
Helped-by: oni-link <knil.ino@gmail.com> Reviewed-by: oni-link <knil.ino@gmail.com>
Diffstat (limited to 'src/nvim/event/pty_process.c')
-rw-r--r--src/nvim/event/pty_process.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/nvim/event/pty_process.c b/src/nvim/event/pty_process.c
index 1e24d7c919..8eef72f12f 100644
--- a/src/nvim/event/pty_process.c
+++ b/src/nvim/event/pty_process.c
@@ -33,17 +33,18 @@
# include "event/pty_process.c.generated.h"
#endif
-static const unsigned int KILL_RETRIES = 5;
-static const unsigned int KILL_TIMEOUT = 2; // seconds
-
bool pty_process_spawn(PtyProcess *ptyproc)
FUNC_ATTR_NONNULL_ALL
{
+ static struct termios termios;
+ if (!termios.c_cflag) {
+ init_termios(&termios);
+ }
+
Process *proc = (Process *)ptyproc;
+ assert(!proc->err);
uv_signal_start(&proc->loop->children_watcher, chld_handler, SIGCHLD);
ptyproc->winsize = (struct winsize){ptyproc->height, ptyproc->width, 0, 0};
- struct termios termios;
- init_termios(&termios);
uv_disable_stdio_inheritance();
int master;
int pid = forkpty(&master, NULL, &termios, &ptyproc->winsize);
@@ -73,9 +74,6 @@ bool pty_process_spawn(PtyProcess *ptyproc)
if (proc->out && !set_duplicating_descriptor(master, &proc->out->uv.pipe)) {
goto error;
}
- if (proc->err && !set_duplicating_descriptor(master, &proc->err->uv.pipe)) {
- goto error;
- }
ptyproc->tty_fd = master;
proc->pid = pid;
@@ -83,19 +81,8 @@ bool pty_process_spawn(PtyProcess *ptyproc)
error:
close(master);
-
- // terminate spawned process
- kill(pid, SIGTERM);
- int status, child;
- unsigned int try = 0;
- while (try++ < KILL_RETRIES && !(child = waitpid(pid, &status, WNOHANG))) {
- sleep(KILL_TIMEOUT);
- }
- if (child != pid) {
- kill(pid, SIGKILL);
- waitpid(pid, NULL, 0);
- }
-
+ kill(pid, SIGKILL);
+ waitpid(pid, NULL, 0);
return false;
}
@@ -152,7 +139,6 @@ static void init_child(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL
static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL
{
- memset(termios, 0, sizeof(struct termios));
// Taken from pangoterm
termios->c_iflag = ICRNL|IXON;
termios->c_oflag = OPOST|ONLCR;