Skip to content

Commit

Permalink
Handle exit code for segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
W2Wizard committed May 11, 2024
1 parent fe4f202 commit dfc1bfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions projects/lib/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { describe, expect, it, beforeAll, afterAll } from "bun:test";
*
* Might be useful for code execution of C files directly:
* @see https://github.com/TinyCC/tinycc
*
* TODO: What happens when you segfault in a function?
*/
//=============================================================================

Expand Down Expand Up @@ -115,9 +113,11 @@ const { symbols, close } = dlopen("libft.so", {

afterAll(close);
beforeAll(() => {
["SIGINT", "SIGTERM", "SIGHUP"].forEach((signal) => {
// Signal for segfault is:
["SIGINT", "SIGTERM", "SIGHUP", "SIGSEGV"].forEach((signal) => {
process.on(signal, () => {
close();
console.error(`Signal ${signal} received.`);
throw new Error(`Signal ${signal} received.`);
});
});
Expand Down
1 change: 1 addition & 0 deletions src/single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export namespace Single {
switch (await container.wait()) {
case 1:
case 2:
case 139:
case 127:
return new Response(response.body, {
status: 422
Expand Down

0 comments on commit dfc1bfb

Please sign in to comment.