Added function crash_prog() to userland/libc

This commit is contained in:
Guru Prasad Srinivasa 2016-02-29 20:11:28 -05:00
parent d466eb7102
commit e51ebc0b1a
2 changed files with 15 additions and 0 deletions

View File

@ -55,4 +55,6 @@ void vwarnx(const char *fmt, __va_list);
__DEAD void verr(int exitcode, const char *fmt, __va_list); __DEAD void verr(int exitcode, const char *fmt, __va_list);
__DEAD void verrx(int exitcode, const char *fmt, __va_list); __DEAD void verrx(int exitcode, const char *fmt, __va_list);
void crash_prog(void);
#endif /* _ERR_H_ */ #endif /* _ERR_H_ */

View File

@ -139,6 +139,8 @@ verr(int exitcode, const char *fmt, va_list ap)
{ {
__printerr(1, fmt, ap); __printerr(1, fmt, ap);
exit(exitcode); exit(exitcode);
// exit() didn't work.
crash_prog();
} }
/* errx/verrx: don't use errno, but do then exit */ /* errx/verrx: don't use errno, but do then exit */
@ -147,6 +149,8 @@ verrx(int exitcode, const char *fmt, va_list ap)
{ {
__printerr(0, fmt, ap); __printerr(0, fmt, ap);
exit(exitcode); exit(exitcode);
// exit() didn't work.
crash_prog();
} }
/* /*
@ -189,3 +193,12 @@ errx(int exitcode, const char *fmt, ...)
verrx(exitcode, fmt, ap); verrx(exitcode, fmt, ap);
va_end(ap); va_end(ap);
} }
void
crash_prog(void)
{
// Guru: Since exit() may not yet be implemented, just trigger a
// failure so things don't fall through to a success print
nprintf("Accessing invalid memory location to trigger failure\n");
tprintf("%d", *((int *) 0xd34db33f));
}