Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return EXIT_FAILURE when c_die called #192

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions cmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int va_system(char *str, ...) {
}

/* What we do when we're all set to exit */
void finish(void) {
void finish(int can_exit) {
curs_set(1);
clear();
refresh();
Expand All @@ -118,32 +118,22 @@ void finish(void) {
va_system("setfont");
#endif
}
exit(0);
if (can_exit)
exit(EXIT_SUCCESS);
}

/* What we do when we're all set to exit */
void c_die(char *msg, ...) {

va_list ap;

curs_set(1);
clear();
refresh();
resetty();
endwin();

if (console) {
#ifdef HAVE_CONSOLECHARS
va_system("consolechars -d");
#elif defined(HAVE_SETFONT)
va_system("setfont");
#endif
}
finish(0);

va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
exit(0);

exit(EXIT_FAILURE);
}

void usage(void) {
Expand Down Expand Up @@ -403,7 +393,7 @@ int main(int argc, char *argv[]) {
case 'h':
case '?':
usage();
exit(0);
exit(EXIT_SUCCESS);
case 'o':
oldstyle = 1;
break;
Expand All @@ -415,7 +405,7 @@ int main(int argc, char *argv[]) {
break;
case 'V':
version();
exit(0);
exit(EXIT_SUCCESS);
case 'r':
rainbow = 1;
break;
Expand Down Expand Up @@ -545,7 +535,7 @@ if (console) {
/* Check for signals */
if (signal_status == SIGINT || signal_status == SIGQUIT) {
if (lock != 1)
finish();
finish(1);
/* exits */
}
if (signal_status == SIGWINCH) {
Expand All @@ -555,7 +545,7 @@ if (console) {

if (signal_status == SIGTSTP) {
if (lock != 1)
finish();
finish(1);
}
#endif

Expand All @@ -578,15 +568,15 @@ if (console) {
ioctl(STDIN_FILENO, TIOCSTI, (char*)(str + i));
free(str);
#endif
finish();
finish(1);
} else {
switch (keypress) {
#ifdef _WIN32
case 3: /* Ctrl-C. Fall through */
#endif
case 'q':
if (lock != 1)
finish();
finish(1);
break;
case 'a':
asynch = 1 - asynch;
Expand Down Expand Up @@ -890,5 +880,5 @@ if (console) {

napms(update * 10);
}
finish();
finish(1);
}