| 88 | } |
| 89 | |
| 90 | function beChild() { |
| 91 | const inspector = require('inspector'); |
| 92 | |
| 93 | process.send({ cmd: 'started' }); |
| 94 | |
| 95 | process.on('message', common.mustCall((msg) => { |
| 96 | if (msg.cmd === 'open') { |
| 97 | if (msg.args[0] === kFirstOpen) { |
| 98 | inspector.open(0, false, undefined); |
| 99 | } else if (msg.args[0] === kOpenWhileOpen) { |
| 100 | assert.throws(() => { |
| 101 | inspector.open(0, false, undefined); |
| 102 | }, { |
| 103 | code: 'ERR_INSPECTOR_ALREADY_ACTIVATED' |
| 104 | }); |
| 105 | } else if (msg.args[0] === kReOpen) { |
| 106 | inspector.open(0, false, undefined); |
| 107 | } |
| 108 | } |
| 109 | if (msg.cmd === 'close') { |
| 110 | inspector.close(); |
| 111 | } |
| 112 | process.send({ cmd: 'url', url: inspector.url() }); |
| 113 | })); |
| 114 | } |