diff options
| author | Curtis McEnroe | 2018-08-04 21:23:28 -0400 | 
|---|---|---|
| committer | Curtis McEnroe | 2018-08-04 21:23:28 -0400 | 
| commit | 6df61b5dda6a07bb1187404e9bdf2579a8cad2ae (patch) | |
| tree | 14e3afd9098c386ac7867c7c6cd152c5d3c4913a /chat.c | |
| parent | 8fdf2c402d23b52868b9208c9d450281c3772c11 (diff) | |
Show source link on exit
Diffstat (limited to 'chat.c')
| -rw-r--r-- | chat.c | 12 | 
1 files changed, 11 insertions, 1 deletions
| @@ -19,6 +19,7 @@  #include <err.h>  #include <errno.h>  #include <poll.h> +#include <signal.h>  #include <stdio.h>  #include <stdlib.h>  #include <string.h> @@ -27,7 +28,14 @@  #include "chat.h" -char *prompt(const char *prompt) { +static void sigint(int sig) { +	(void)sig; +	input(L"/quit"); +	uiHide(); +	exit(EX_OK); +} + +static char *prompt(const char *prompt) {  	char *line = NULL;  	size_t cap;  	for (;;) { @@ -67,6 +75,8 @@ int main(int argc, char *argv[]) {  	if (!chat.nick) chat.nick = prompt("Name: ");  	chat.user = strdup(chat.nick); +	signal(SIGINT, sigint); +  	uiInit();  	uiLog("Traveling...");  	uiDraw(); | 
