From 3bcce95be3ca1761cd176869ca03faffe732ac7b Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 27 Mar 2012 13:30:42 +0200 Subject: [PATCH] pty: add kmscon_pty_signal() Allow to send arbitrary signals to the foreground process group of the pty. Linux supports the TIOCSIG ioctl so we actually do not need to implement this on our own, yeah! Signed-off-by: David Herrmann --- src/pty.c | 16 ++++++++++++++++ src/pty.h | 6 +----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pty.c b/src/pty.c index 2a03121..920473a 100644 --- a/src/pty.c +++ b/src/pty.c @@ -428,6 +428,22 @@ buf: return 0; } +void kmscon_pty_signal(struct kmscon_pty *pty, int signum) +{ + int ret; + + if (!pty || !pty_is_open(pty) || signum < 0) + return; + + ret = ioctl(pty->fd, TIOCSIG, signum); + if (ret) { + log_warn("cannot send signal %d to child", signum); + return; + } + + log_debug("send signal %d to child", signum); +} + void kmscon_pty_resize(struct kmscon_pty *pty, unsigned short width, unsigned short height) { diff --git a/src/pty.h b/src/pty.h index 675cc17..d8d9214 100644 --- a/src/pty.h +++ b/src/pty.h @@ -60,11 +60,7 @@ int kmscon_pty_open(struct kmscon_pty *pty, unsigned short width, void kmscon_pty_close(struct kmscon_pty *pty); int kmscon_pty_write(struct kmscon_pty *pty, const char *u8, size_t len); - -/* - * Call this whenever the size of the screen (rows or columns) changes. The - * kernel and child process need to be notified. - */ +void kmscon_pty_signal(struct kmscon_pty *pty, int signum); void kmscon_pty_resize(struct kmscon_pty *pty, unsigned short width, unsigned short height);