-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android fixes #6733
Android fixes #6733
Conversation
In case of x86 arch, the target_arch variables passed through GYP_DEFINES is also x86. But, this value is not recognized by gyp files, so we need to pass ia32 instead. For x86 arch, we need to pass the value of DEST_CPU, which is ia32. Signed-off-by: Robert Chiras <robert.chiras@intel.com>
In execSync/execFileSync commands, we better verify the stderr buffer from ret. In case of other exceptions thrown by spawnSync this buffer might be null. If we don't check it and try to write it to process.stderr we will end up throwing an irrelevant exception from Socket.write, masking the initial exception which might show what is actually wrong with spawnSync. Such an exception was hidden, when running this test on Android. The exception was about '/bin/sh' not found, since in Android, sh can be found in '/system/bin/sh'. Signed-off-by: Robert Chiras <robert.chiras@intel.com>
The second commit doesn't look obviously correct to me. If the issue is the location of diff --git a/lib/child_process.js b/lib/child_process.js
index 81fb8c1..4fda6e2 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -332,7 +332,12 @@ function normalizeSpawnArguments(file /*, args, options*/) {
args = ['/s', '/c', '"' + command + '"'];
options.windowsVerbatimArguments = true;
} else {
- file = typeof options.shell === 'string' ? options.shell : '/bin/sh';
+ if (typeof options.shell === 'string')
+ file = options.shell;
+ else if (process.platform === 'android')
+ file = '/system/bin/sh';
+ else
+ file = '/bin/sh';
args = ['-c', command];
}
} |
The second commit is intended to not mask any other exceptions. The exception I met and described is just an example. This is why, I consider it might be a good fix. diff --git a/test/sequential/test-child-process-emfile.js b/test/sequential/test-child-process-emfile.js
index f186db5..961f37c 100644
--- a/test/sequential/test-child-process-emfile.js
+++ b/test/sequential/test-child-process-emfile.js
@@ -9,13 +9,19 @@ if (common.isWindows) {
return;
}
-const ulimit = Number(child_process.execSync('ulimit -Hn'));
+var sh = '/bin/sh'
+var opts = {}
+if (process.platform === 'android') {
+ sh = '/system/bin/sh'
+ opts = {shell: sh}
+}
+const ulimit = Number(child_process.execSync('ulimit -Hn', opts));
if (ulimit > 64 || Number.isNaN(ulimit)) {
// Sorry about this nonsense. It can be replaced if
// https://github.com/nodejs/node-v0.x-archive/pull/2143#issuecomment-2847886
// ever happens.
const result = child_process.spawnSync(
- '/bin/sh',
+ sh,
['-c', `ulimit -n 64 && '${process.execPath}' '${__filename}'`]
);
assert.strictEqual(result.stdout.toString(), ''); But, I think that your proposed fix is better, since we won't have to handle this situation in every test using execSync. |
Okay, I understand now. Can you add a regression test to the second commit that exercises the stderr-is-falsy code path? I filed #6745 for the |
`/bin/sh` does not exist on Android but `/system/bin/sh` does. PR-URL: nodejs#6745 Refs: nodejs#6733 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
ping @robertchiras do you find some time to work on this? #6745 landed. Thanks! |
Hi @eljefedelrodeodeljefe |
Very grateful @robertchiras. Looking forward to it. I am collecting similar issues across the repo. After we land the stalled stuff I am gonna have a look at building latest too. Thanks again. |
Checklist
Affected core subsystem(s)
build, child_process
Description of change
Small fixes found when running on Android platform.