Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c0cf173

Browse filesBrowse files
bnoordhuistargos
authored andcommitted
src: ignore SIGXFSZ, don't terminate (ulimit -f)
Ignore SIGXFSZ signals so that exceeding RLIMIT_FSIZE makes the offending system call fail with EFBIG instead of terminating the process. PR-URL: #27798 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 3b6424f commit c0cf173
Copy full SHA for c0cf173

File tree

Expand file treeCollapse file tree

2 files changed

+33
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+33
-1
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ inline void PlatformInit() {
491491
for (unsigned nr = 1; nr < kMaxSignal; nr += 1) {
492492
if (nr == SIGKILL || nr == SIGSTOP)
493493
continue;
494-
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
494+
act.sa_handler = (nr == SIGPIPE || nr == SIGXFSZ) ? SIG_IGN : SIG_DFL;
495495
CHECK_EQ(0, sigaction(nr, &act, nullptr));
496496
}
497497
#endif // !NODE_SHARED_MODE
Collapse file
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Check that exceeding RLIMIT_FSIZE fails with EFBIG
2+
// rather than terminating the process with SIGXFSZ.
3+
'use strict';
4+
const common = require('../common');
5+
const tmpdir = require('../common/tmpdir');
6+
7+
const assert = require('assert');
8+
const child_process = require('child_process');
9+
const fs = require('fs');
10+
const path = require('path');
11+
12+
if (common.isWindows)
13+
common.skip('no RLIMIT_FSIZE on Windows');
14+
15+
if (process.config.variables.node_shared)
16+
common.skip('SIGXFSZ signal handler not installed in shared library mode');
17+
18+
if (process.argv[2] === 'child') {
19+
const filename = path.join(tmpdir.path, 'efbig.txt');
20+
tmpdir.refresh();
21+
fs.writeFileSync(filename, '.'.repeat(1 << 16)); // Exceeds RLIMIT_FSIZE.
22+
} else {
23+
const cmd = `ulimit -f 1 && '${process.execPath}' '${__filename}' child`;
24+
const result = child_process.spawnSync('/bin/sh', ['-c', cmd]);
25+
const haystack = result.stderr.toString();
26+
const needle = 'Error: EFBIG: file too large, write';
27+
const ok = haystack.includes(needle);
28+
if (!ok) console.error(haystack);
29+
assert(ok);
30+
assert.strictEqual(result.status, 1);
31+
assert.strictEqual(result.stdout.toString(), '');
32+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.