aboutsummaryrefslogtreecommitdiff
path: root/client-msg.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-18 12:09:42 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-18 12:09:42 +0000
commit8ea49712fd4c9f158128832e6c93308afeb1bd4d (patch)
treea7a4e84c2722ba9f3848f4bbe377c1e38ed14d1c /client-msg.c
parent273d63040ab6f0124518fcdb1ad9f2f10c84c2de (diff)
downloadrtmux-8ea49712fd4c9f158128832e6c93308afeb1bd4d.tar.gz
rtmux-8ea49712fd4c9f158128832e6c93308afeb1bd4d.tar.bz2
rtmux-8ea49712fd4c9f158128832e6c93308afeb1bd4d.zip
suspend-client command and suspend client when ^Z key binding is used.
Diffstat (limited to 'client-msg.c')
-rw-r--r--client-msg.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/client-msg.c b/client-msg.c
index 3510e3ac..7f2f3dca 100644
--- a/client-msg.c
+++ b/client-msg.c
@@ -1,4 +1,4 @@
-/* $Id: client-msg.c,v 1.16 2009-01-07 22:57:03 nicm Exp $ */
+/* $Id: client-msg.c,v 1.17 2009-01-18 12:09:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,8 +29,7 @@ int client_msg_fn_detach(struct hdr *, struct client_ctx *, char **);
int client_msg_fn_error(struct hdr *, struct client_ctx *, char **);
int client_msg_fn_exit(struct hdr *, struct client_ctx *, char **);
int client_msg_fn_exited(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_okay(struct hdr *, struct client_ctx *, char **);
-int client_msg_fn_pause(struct hdr *, struct client_ctx *, char **);
+int client_msg_fn_suspend(struct hdr *, struct client_ctx *, char **);
struct client_msg {
enum hdrtype type;
@@ -40,7 +39,8 @@ struct client_msg client_msg_table[] = {
{ MSG_DETACH, client_msg_fn_detach },
{ MSG_ERROR, client_msg_fn_error },
{ MSG_EXIT, client_msg_fn_exit },
- { MSG_EXITED, client_msg_fn_exited }
+ { MSG_EXITED, client_msg_fn_exited },
+ { MSG_SUSPEND, client_msg_fn_suspend },
};
int
@@ -116,3 +116,29 @@ client_msg_fn_exited(
return (-1);
}
+
+int
+client_msg_fn_suspend(
+ struct hdr *hdr, unused struct client_ctx *cctx, unused char **error)
+{
+ struct sigaction act;
+
+ if (hdr->size != 0)
+ fatalx("bad MSG_SUSPEND size");
+
+ memset(&act, 0, sizeof act);
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_RESTART;
+
+ act.sa_handler = SIG_DFL;
+ if (sigaction(SIGTSTP, &act, NULL) != 0)
+ fatal("sigaction failed");
+
+ act.sa_handler = sighandler;
+ if (sigaction(SIGCONT, &act, NULL) != 0)
+ fatal("sigaction failed");
+
+ kill(getpid(), SIGTSTP);
+
+ return (0);
+}