0
私はVisual Studio Codeの拡張機能を開発中です。子プロセスをforkする必要があります。プロセスは終了したり、メッセージを送信したり、実行中であるとは思われません(子プロセスからファイルを書き出して、実行中であることを確認しようとしました)。ここでVisual Studioコード拡張:child_process.forkが機能しません。
は子プロセスをforkための私のコードです:
let process = require('child_process').fork('./child', [], {});
process.on('message', message => console.log('message: ' + message)); // handler is never called
process.on('exit', code => console.log('exited with code ' + code)); // handler is never called
はここchild.jsです:
require('fs').writeFileSync(__dirname + '/hello.txt', 'Hello', 'utf8'); // file never gets written
process.send('hello');
予想通りspawn('node', [__dirname + '/child.js'], {})
作品で同じスクリプトを実行しようとしていることに留意すべきです。
これをデバッグインスタンスでテストするだけです。私は間違って何をしていますか?