Removed all instances of crash_prog()
crash_prog was introduced to force-crash a userspace program since _exit may not yet be implemented. However, the new versions of OS161 already have the exact same logic as crash_prog in stdlib/exit.
This commit is contained in:
parent
a07a4b75c1
commit
2cb47cb4c8
@ -55,6 +55,4 @@ void vwarnx(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);
|
||||
|
||||
void crash_prog(void);
|
||||
|
||||
#endif /* _ERR_H_ */
|
||||
|
@ -140,7 +140,6 @@ verr(int exitcode, const char *fmt, va_list ap)
|
||||
__printerr(1, fmt, ap);
|
||||
exit(exitcode);
|
||||
// exit() didn't work.
|
||||
crash_prog();
|
||||
}
|
||||
|
||||
/* errx/verrx: don't use errno, but do then exit */
|
||||
@ -150,7 +149,6 @@ verrx(int exitcode, const char *fmt, va_list ap)
|
||||
__printerr(0, fmt, ap);
|
||||
exit(exitcode);
|
||||
// exit() didn't work.
|
||||
crash_prog();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -193,12 +191,3 @@ errx(int exitcode, const char *fmt, ...)
|
||||
verrx(exitcode, fmt, 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));
|
||||
}
|
||||
|
@ -75,7 +75,5 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
success(TEST161_SUCCESS, SECRET, "/testbin/closetest");
|
||||
// Exit may not be implemented. So crash.
|
||||
crash_prog();
|
||||
return 0;
|
||||
}
|
||||
|
@ -54,11 +54,5 @@ main(int argc, char **argv)
|
||||
(void) argv;
|
||||
|
||||
secprintf(SECRET, "Able was i ere i saw elbA", "/testbin/consoletest");
|
||||
|
||||
// Guru: Since exit() may not yet be implemented, just trigger a
|
||||
// failure that the grading scripts expect to see.
|
||||
tprintf("Accessing invalid memory location to trigger failure\n");
|
||||
tprintf("%d", *((int *) 0xd34db33f));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,7 +162,5 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
success(TEST161_SUCCESS, SECRET, "/testbin/fileonlytest");
|
||||
// Exit may not be implemented. So crash.
|
||||
crash_prog();
|
||||
return 0;
|
||||
}
|
||||
|
@ -75,8 +75,5 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
success(TEST161_SUCCESS, SECRET, "/testbin/opentest");
|
||||
|
||||
// Exit may not be implemented. So crash.
|
||||
crash_prog();
|
||||
return 0;
|
||||
}
|
||||
|
@ -100,7 +100,5 @@ main(int argc, char **argv)
|
||||
nprintf("\n");
|
||||
|
||||
secprintf(SECRET, MAGIC, "/testbin/readwritetest");
|
||||
// Exit may not be implemented. So crash.
|
||||
crash_prog();
|
||||
return 0;
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ doopen(const char *path, int openflags)
|
||||
fd = open(path, openflags, 0664);
|
||||
if (fd < 0) {
|
||||
err(1, "%s", path);
|
||||
crash_prog();
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
@ -77,7 +76,6 @@ dodup2(int ofd, int nfd, const char *file)
|
||||
}
|
||||
if (r != nfd) {
|
||||
errx(1, "%s: dup2: Expected %d, got %d", nfd, r);
|
||||
crash_prog();
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,12 +100,10 @@ mkfile(void)
|
||||
r = write(fd, slogan, strlen(slogan));
|
||||
if (r < 0) {
|
||||
err(1, "%s: write", INFILE);
|
||||
crash_prog();
|
||||
}
|
||||
if ((size_t)r != strlen(slogan)) {
|
||||
errx(1, "%s: write: Short count (got %zd, expected %zu)",
|
||||
INFILE, r, strlen(slogan));
|
||||
crash_prog();
|
||||
}
|
||||
|
||||
doclose(fd, INFILE);
|
||||
@ -126,16 +122,13 @@ chkfile(void)
|
||||
r = read(fd, buf, sizeof(buf));
|
||||
if (r < 0) {
|
||||
err(1, "%s: read", OUTFILE);
|
||||
crash_prog();
|
||||
}
|
||||
if (r == 0) {
|
||||
errx(1, "%s: read: Unexpected EOF", OUTFILE);
|
||||
crash_prog();
|
||||
}
|
||||
if ((size_t)r != strlen(slogan)) {
|
||||
errx(1, "%s: read: Short count (got %zd, expected %zu)",
|
||||
OUTFILE, r, strlen(slogan));
|
||||
crash_prog();
|
||||
}
|
||||
|
||||
doclose(fd, OUTFILE);
|
||||
@ -155,7 +148,6 @@ cat(void)
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
err(1, "fork");
|
||||
crash_prog();
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
@ -178,15 +170,12 @@ cat(void)
|
||||
result = waitpid(pid, &status, 0);
|
||||
if (result == -1) {
|
||||
err(1, "waitpid");
|
||||
crash_prog();
|
||||
}
|
||||
if (WIFSIGNALED(status)) {
|
||||
errx(1, "pid %d: Signal %d", (int)pid, WTERMSIG(status));
|
||||
crash_prog();
|
||||
}
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
|
||||
errx(1, "pid %d: Exit %d", (int)pid, WEXITSTATUS(status));
|
||||
crash_prog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,5 @@ main(int argc, char *argv[])
|
||||
|
||||
nprintf("\n");
|
||||
success(TEST161_SUCCESS, SECRET, "/testbin/sparsefile");
|
||||
// Exit may not be implemented. So crash.
|
||||
crash_prog();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user