Added atexit callback, for ctrl-c cleanup
This commit is contained in:
2
main.c
2
main.c
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
profanity_init(disable_tls);
|
profanity_init(disable_tls);
|
||||||
profanity_run();
|
profanity_run();
|
||||||
profanity_shutdown();
|
//profanity_shutdown();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
|
||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
|
|
||||||
|
static void _profanity_shutdown(void);
|
||||||
|
|
||||||
void profanity_run(void)
|
void profanity_run(void)
|
||||||
{
|
{
|
||||||
int cmd_result = TRUE;
|
int cmd_result = TRUE;
|
||||||
@@ -43,7 +45,6 @@ void profanity_run(void)
|
|||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
while(ch != '\n') {
|
while(ch != '\n') {
|
||||||
usleep(1);
|
|
||||||
gui_refresh();
|
gui_refresh();
|
||||||
jabber_process_events();
|
jabber_process_events();
|
||||||
win_handle_switch(&ch);
|
win_handle_switch(&ch);
|
||||||
@@ -64,9 +65,10 @@ void profanity_init(const int disable_tls)
|
|||||||
gui_init();
|
gui_init();
|
||||||
jabber_init(disable_tls);
|
jabber_init(disable_tls);
|
||||||
history_init();
|
history_init();
|
||||||
|
atexit(_profanity_shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void profanity_shutdown(void)
|
void _profanity_shutdown(void)
|
||||||
{
|
{
|
||||||
jabber_disconnect();
|
jabber_disconnect();
|
||||||
gui_close();
|
gui_close();
|
||||||
|
|||||||
Reference in New Issue
Block a user