@@ 33,7 33,6 @@ void on_call_retract(const char *chat_id, void *dummy) {
(void)dummy;
snikket_release(chat_id);
puts("Hung up...");
- chat = NULL; // So we don't call hangup again
if (!exiting) exit(0);
}
@@ 41,7 40,11 @@ void on_call_retract(const char *chat_id, void *dummy) {
void sigint_handler(int sig) {
(void)sig;
puts("Hang up...");
- exit(0);
+ exiting = true;
+ snikket_chat_hangup(chat);
+ sleep(3); // Give time for hangup to send, etc
+
+ _exit(0);
}
// Audio track got some from the other side, so let's play it
@@ 176,21 179,6 @@ void on_password_needed(void *client, void *password) {
snikket_release(client);
}
-void at_exit(void) {
- exiting = true;
-
- // If it was us, send the hangup signal
- if (chat) {
- snikket_chat_hangup(chat);
- sleep(3); // Give time for hangup to send, etc
- }
-
- // We could release stuff here, but we're gonna exit anyway
-
- // Stop the SDK, no waiting
- snikket_stop(false);
-}
-
int main(int argc, const char **argv) {
const char *err;
@@ 208,9 196,6 @@ int main(int argc, const char **argv) {
return 1;
}
- // Set cleanup hook
- atexit(&at_exit);
-
// And make a persistence layer
void *persistence = snikket_persistence_dummy_new();
@@ 255,5 240,6 @@ int main(int argc, const char **argv) {
if (dtmf) snikket_jingle_dtmf_sender_insert_dtmf(dtmf, tone);
}
+ sigint_handler(SIGINT);
return 0;
}