Hi JuneBug!
diff --git a/chat.c b/chat.c
index 8c425d4..79ef097 100644
--- a/chat.c
+++ b/chat.c
@@ -97,6 +97,7 @@ static void exitSave(void) {
}
}
+time_t lastsigint = 0;
uint execID;
int execPipe[2] = { -1, -1 };
int utilPipe[2] = { -1, -1 };
@@ -239,6 +240,7 @@ int main(int argc, char *argv[]) {
char *pass = NULL;
const char *user = NULL;
const char *real = NULL;
+ time_t now;
struct option options[] = {
{ .val = '!', .name = "insecure", no_argument },
@@ -447,7 +449,20 @@ int main(int argc, char *argv[]) {
}
if (signals[SIGHUP]) self.quit = "zzz";
- if (signals[SIGINT] || signals[SIGTERM]) break;
+ if (signals[SIGINT]) {
+ now = time(NULL);
+ if (difftime(now, lastsigint) <= 1.0)
+ break;
+ else
+ uiFormat(
+ Network, Warm, NULL,
+ "SIGINT (^C) registewed only if you "
+ "pwess me again within one second"
+ );
+
+ lastsigint = now;
+ }
+ if (signals[SIGTERM]) break;
if (nfds > 0 && fds[1].revents) {
ping = false;
I tested this, it seems to work. Thanks for catgirl!
-peter
--
Over thirty years experience on Unix-like Operating Systems starting with QNX.
On Tue, Aug 22, 2023 at 06:51:48AM +0200, Peter J. Philipp wrote:
> + "SIGINT (^C) registewed only if you "
> + "pwess me again within one second"
> + );
I'd consider that an annoyance rather than a feature.
Two alternatives approaches that come to mind:
- bind ^C in tmux, see catgirl's scripts/chat.tmux.conf for an example
- `stty intr undef' in the terminal before starting catgirl, then use
another signal/key-combo or `/quit' to terminate/exit catgirl
On 8/22/23 08:03, Klemens Nanni wrote:
> On Tue, Aug 22, 2023 at 06:51:48AM +0200, Peter J. Philipp wrote:
>> + "SIGINT (^C) registewed only if you "
>> + "pwess me again within one second"
>> + );
> I'd consider that an annoyance rather than a feature.
> Two alternatives approaches that come to mind:
>
> - bind ^C in tmux, see catgirl's scripts/chat.tmux.conf for an example
>
> - `stty intr undef' in the terminal before starting catgirl, then use
> another signal/key-combo or `/quit' to terminate/exit catgirl
OK gotcha. Yes the 2nd one is what I prefer, tested it too. Thanks!
-peter
--
Over thirty years experience on Unix-like Operating Systems starting with QNX.