11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Test exec() with both a timeout and a killSignal. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst common = require('../common'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst cp = require('child_process'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst { 101cb0ef41Sopenharmony_ci cleanupStaleProcess, 111cb0ef41Sopenharmony_ci logAfterTime, 121cb0ef41Sopenharmony_ci kExpiringChildRunTime, 131cb0ef41Sopenharmony_ci kExpiringParentTimer, 141cb0ef41Sopenharmony_ci} = require('../common/child_process'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') { 171cb0ef41Sopenharmony_ci logAfterTime(kExpiringChildRunTime); 181cb0ef41Sopenharmony_ci return; 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst cmd = `"${process.execPath}" "${__filename}" child`; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci// Test with a different kill signal. 241cb0ef41Sopenharmony_cicp.exec(cmd, { 251cb0ef41Sopenharmony_ci timeout: kExpiringParentTimer, 261cb0ef41Sopenharmony_ci killSignal: 'SIGKILL' 271cb0ef41Sopenharmony_ci}, common.mustCall((err, stdout, stderr) => { 281cb0ef41Sopenharmony_ci console.log('[stdout]', stdout.trim()); 291cb0ef41Sopenharmony_ci console.log('[stderr]', stderr.trim()); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci assert.strictEqual(err.killed, true); 321cb0ef41Sopenharmony_ci assert.strictEqual(err.code, null); 331cb0ef41Sopenharmony_ci assert.strictEqual(err.signal, 'SIGKILL'); 341cb0ef41Sopenharmony_ci assert.strictEqual(err.cmd, cmd); 351cb0ef41Sopenharmony_ci assert.strictEqual(stdout.trim(), ''); 361cb0ef41Sopenharmony_ci assert.strictEqual(stderr.trim(), ''); 371cb0ef41Sopenharmony_ci})); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_cicleanupStaleProcess(__filename); 40