aboutsummaryrefslogtreecommitdiff
path: root/vterm-module.c
diff options
context:
space:
mode:
authorLukas Fürmetz <fuermetz@mailbox.org>2017-07-26 17:03:35 +0200
committerLukas Fürmetz <fuermetz@mailbox.org>2017-07-26 17:24:03 +0200
commit2f0c340d8923284fdcd6e1eeac9db724103c84ed (patch)
treeb97a1ed2f524780589b2939e202f109d4c85cafe /vterm-module.c
parentd4c3ee244ce020a7e7a032f6989bdc4c5e428235 (diff)
Terminate process if corresponding buffer is killed
Diffstat (limited to 'vterm-module.c')
-rw-r--r--vterm-module.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vterm-module.c b/vterm-module.c
index b7a0e01..6f169c2 100644
--- a/vterm-module.c
+++ b/vterm-module.c
@@ -1,6 +1,7 @@
#include "vterm-module.h"
#include <fcntl.h>
#include <pty.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -348,6 +349,15 @@ static emacs_value Fvterm_update(emacs_env *env, ptrdiff_t nargs,
return env->make_integer(env, 0);
}
+static emacs_value Fvterm_kill(emacs_env *env, ptrdiff_t nargs,
+ emacs_value args[], void *data) {
+ struct Term *term = env->get_user_ptr(env, args[0]);
+ kill(term->pid, SIGKILL);
+ int status;
+ waitpid(term->pid, &status, 0);
+ return env->intern(env, "nil");
+}
+
int emacs_module_init(struct emacs_runtime *ert) {
emacs_env *env = ert->get_environment(ert);
emacs_value fun;
@@ -357,9 +367,13 @@ int emacs_module_init(struct emacs_runtime *ert) {
bind_function(env, "vterm-new", fun);
fun = env->make_function(env, 1, 5, Fvterm_update,
- "Process io and updates the screen.", NULL);
+ "Process io and update the screen.", NULL);
bind_function(env, "vterm-update", fun);
+ fun = env->make_function(env, 1, 1, Fvterm_kill,
+ "Kill the the shell process.", NULL);
+ bind_function(env, "vterm-kill", fun);
+
provide(env, "vterm-module");
return 0;