'use strict';

// MODULES //

var debug = require( 'debug' )( 'parallel:worker:close' );
var getKeys = require( 'object-keys' ).shim();
var proc = require( './process.js' );
var db = require( './children.js' );


// MAIN //

/**
* Closes all child processes.
*
* @private
*/
function close() {
	var keys;
	var pid;
	var i;

	debug( 'Killing all child processes...' );
	keys = getKeys( db );
	for ( i = 0; i < keys.length; i++ ) {
		pid = keys[ i ];
		debug( 'Killing child process (pid: %d)...', pid );
		db[ pid ].kill();
		delete db[ pid ];
	}
	// Disconnect this process from the parent to allow this process to gracefully close:
	debug( 'Disconnecting worker from parent process...' );
	proc.disconnect();
} // end FUNCTION close()


// EXPORTS //

module.exports = close;

'use strict';

// MODULES //

var debug = require( 'debug' )( 'parallel:worker:close' );
var getKeys = require( 'object-keys' ).shim();
var proc = require( './process.js' );
var db = require( './children.js' );


// MAIN //

/**
* Closes all child processes.
*
* @private
*/
function close() { // eslint-disable-line no-redeclare
	var keys;
	var pid;
	var i;

	debug( 'Killing all child processes...' );
	keys = getKeys( db );
	for ( i = 0; i < keys.length; i++ ) {
		pid = keys[ i ];
		debug( 'Killing child process (pid: %d)...', pid );
		db[ pid ].kill();
		delete db[ pid ];
	}
	// Disconnect this process from the parent to allow this process to gracefully close:
	debug( 'Disconnecting worker from parent process...' );
	proc.disconnect();
} // end FUNCTION close()


// EXPORTS //

module.exports = close;

Disable no-redeclare lint rule