11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { Worker, parentPort } = require('worker_threads'); 41cb0ef41Sopenharmony_ciconst fs = require('fs'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Checks that terminating Workers does not crash the process if fs.watchFile() 71cb0ef41Sopenharmony_ci// has active handles. 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Do not use isMainThread so that this test itself can be run inside a Worker. 101cb0ef41Sopenharmony_ciif (!process.env.HAS_STARTED_WORKER) { 111cb0ef41Sopenharmony_ci process.env.HAS_STARTED_WORKER = 1; 121cb0ef41Sopenharmony_ci const worker = new Worker(__filename); 131cb0ef41Sopenharmony_ci worker.on('message', common.mustCall(() => worker.terminate())); 141cb0ef41Sopenharmony_ci} else { 151cb0ef41Sopenharmony_ci fs.watchFile(__filename, () => {}); 161cb0ef41Sopenharmony_ci parentPort.postMessage('running'); 171cb0ef41Sopenharmony_ci} 18