Browse Source

* add cleanup() routine

master
Alex 'AdUser' Z 8 years ago
parent
commit
dd12854d02
  1. 10
      src/client.c

10
src/client.c

@ -77,12 +77,18 @@ handle_cmd(const char *line) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
void cleanup() {
f2b_csocket_disconnect(opts.csocket, opts.csocket_cpath);
unlink(opts.csocket_cpath);
}
void void
signal_handler(int signum) { signal_handler(int signum) {
switch (signum) { switch (signum) {
case SIGINT: case SIGINT:
case SIGTERM: case SIGTERM:
unlink(opts.csocket_cpath); cleanup();
exit(EXIT_SUCCESS);
break; break;
default: default:
break; break;
@ -176,7 +182,7 @@ int main(int argc, char *argv[]) {
line = NULL; line = NULL;
} }
f2b_csocket_disconnect(opts.csocket, opts.csocket_cpath); cleanup();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

Loading…
Cancel
Save