Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,13 @@ program
// Register signal handlers
process.on('SIGINT', async () => {
await performCleanup('SIGINT');
console.error(`Process exiting with code: 130`);
process.exit(130); // Standard exit code for SIGINT
});

process.on('SIGTERM', async () => {
await performCleanup('SIGTERM');
console.error(`Process exiting with code: 143`);
process.exit(143); // Standard exit code for SIGTERM
});

Expand All @@ -585,10 +587,12 @@ program
}
);

console.error(`Process exiting with code: ${exitCode}`);
process.exit(exitCode);
} catch (error) {
logger.error('Fatal error:', error);
await performCleanup();
console.error(`Process exiting with code: 1`);
process.exit(1);
}
});
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/basic-firewall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,26 @@ describe('Basic Firewall Functionality', () => {
await docker.rm('awf-squid', true);
await docker.rm('awf-agent', true);
}, 120000);

test('Test 10: Exit code written to stderr (success)', async () => {
const result = await runner.runWithSudo('exit 0', {
allowDomains: ['github.com'],
logLevel: 'debug',
timeout: 30000,
});

expect(result).toExitWithCode(0);
expect(result.stderr).toContain('Process exiting with code: 0');
}, 120000);

test('Test 11: Exit code written to stderr (failure)', async () => {
const result = await runner.runWithSudo('exit 42', {
allowDomains: ['github.com'],
logLevel: 'debug',
timeout: 30000,
});

expect(result).toExitWithCode(42);
expect(result.stderr).toContain('Process exiting with code: 42');
}, 120000);
});