-
Notifications
You must be signed in to change notification settings - Fork 15k
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
child_process.execSync causes error: write EBADF #3482
Comments
I'm unable to reproduce it, but I think I can guess out the cause. Can you run this code in renderer and then test whether process.stdout._write = function(_, _, callback) {
process.nextTick(function() {
callback(0);
});
} |
It is still causing the same error. > process.stdout._write = function(_, _, callback) {
process.nextTick(function() {
callback(0);
});
}
> require('child_process').execSync('echo $PATH');
events.js:141 Uncaught Error: write EBADF |
Does the error happen if you call |
No. |
@zcbenz After a bit of digging, I realised that it is specific to my app. I've managed to track down a reproducible error scenario, it's very very strange! In main/browser: var foo = console; In renderer: require('child_process').execSync('echo $PATH'); Here's a repo that you can clone to reproduce it: https://github.com/davej/electron-execSync-test |
Tested the repo in my last comment on a different machine machine running OS X 10.11 and also tested on Windows 7. Results are:
This seems to suggest that the bug is OS X specific but not machine dependent. |
Hi in a js this line issues an error if i remove the const console, everything is fine feel free to ask if precision needed Laurent |
@lgodard, the console object is a part of the global object so it's always available and you don't need to require it. The require will always fail, unless you npm install some module called console, so just remove that line. |
It may fail but it shouldn't fail with a bad file descriptor message. |
I agree. It should be |
You're probably correct, it's not impossible that |
Hi, I agree that console.log() works and displays outputs in DevTools window But, at least on linux, using require('console') redirects the output in the console where npm start has been launched. It allows to track all the output messages at once (no external module installed) My point is, it is working for linux but fails on win7 with the "Uncaught Error: EBADF: bad file descriptor, write" message so i can't rely on developping multiplateform Thanks again Laurent |
Seeing this issue in the renderer process (works fine in main process) of 0.34.3 on Yosemite.
child_process.exec
is fine, onlyexecSync
fails.To recreate in the renderer, just do:
The error backtrace:
Possibly related to: #1471
The text was updated successfully, but these errors were encountered: