Skip to content

Commit

Permalink
fixup: cast in cpp, works on win2008, python things
Browse files Browse the repository at this point in the history
  • Loading branch information
bzoz committed Mar 16, 2017
1 parent 15d4f8c commit a73e803
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4215,10 +4215,11 @@ inline void PlatformInit() {
#endif // __POSIX__
#ifdef _WIN32
for (int fd = 0; fd <= 2; ++fd) {
auto handle = (HANDLE) _get_osfhandle(fd);
auto handle = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
if (handle == INVALID_HANDLE_VALUE ||
GetFileType(handle) == FILE_TYPE_UNKNOWN) {
if (_close(fd) || fd != _open("nul", _O_RDWR))
_close(fd);
if (fd != _open("nul", _O_RDWR))
ABORT();
}
}
Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/spawn_closed_stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
os.close(0)
os.close(1)
os.close(2)
cmd = sys.argv[1] + ' -e "process.stdin; process.stdout; process.stderr;"'
exit_code = subprocess.call(cmd, shell=False)
exit_code = subprocess.call(sys.argv[1:4], shell=False)

This comment has been minimized.

Copy link
@addaleax

addaleax Mar 16, 2017

Member

At this point you might as well go with sys.argv[1:], right? (I originally suggested the change because there doesn’t seem to be a need to have this fixture be specific to that one test file)

sys.exit(exit_code)
11 changes: 8 additions & 3 deletions test/parallel/test-stdio-closed.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ const fs = require('fs');
const path = require('path');

if (common.isWindows) {
if (process.argv[2] === 'child') {
process.stdin;
process.stdout;
process.stderr;
process.exit(0);

This comment has been minimized.

Copy link
@addaleax

addaleax Mar 16, 2017

Member

return instead of process.exit(0)?

}
const python = process.env.PYTHON || 'python';
const script = path.join(__dirname, '..', 'fixtures',
'spawn_closed_stdio.py');
const proc = spawn(python, [ script, process.execPath ]);
const script = path.join(common.fixturesDir, 'spawn_closed_stdio.py');
const proc = spawn(python, [script, process.execPath, __filename, 'child']);
proc.on('exit', common.mustCall(function(exitCode) {
assert.strictEqual(exitCode, 0);
}));
Expand Down

0 comments on commit a73e803

Please sign in to comment.