How to use process-exists - 4 common examples

To help you get started, we’ve selected a few process-exists examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orionjs / orionjs / packages / cli / src / start / waitAppStopped.js View on Github external
export default async function() {
  if (!global.appProcess) return
  const pid = global.appProcess.pid
  for (let i = 0; true; i++) {
    // console.log('checking if killed', await processExists(pid))
    if (!(await processExists(pid))) {
      return
    }

    await sleep(100)
    // 10 min
    if (i > 10 * 60 * 10) {
      console.log('App stop timeout')
      return
    }
  }
}
github microlinkhq / browserless / packages / browserless / src / browser / fkill.js View on Github external
const fkill = async (inputs, options = {}) => {
  inputs = arrify(inputs)

  options.tree = options.tree === undefined ? true : options.tree
  options.ignoreCase = options.ignoreCase || process.platform === 'win32'

  const exists = await processExists.all(inputs)

  const errors = []

  const handleKill = async input => {
    try {
      input = await parseInput(input)

      if (input === process.pid) {
        return
      }

      // Handle killall by process name
      if (typeof input === 'string') {
        const processes = await psList()
        const nameRe = new RegExp(`^${input}$`, options.ignoreCase ? 'i' : '')
github ZcashFoundation / zepio / config / daemon / wait-for-daemon-close.js View on Github external
const interval = setInterval(async () => {
    const [, isRunning] = await eres(processExists(processName));

    if (!isRunning) {
      clearInterval(interval);
      setTimeout(resolve, 1000);
    }
  }, 500);
});
github sindresorhus / fkill / index.js View on Github external
const fkill = async (inputs, options = {}) => {
	inputs = arrify(inputs);

	const exists = await processExists.all(inputs);

	const errors = [];

	const handleKill = async input => {
		try {
			input = await parseInput(input);

			if (input === process.pid) {
				return;
			}

			if (input === 'node') {
				const processes = await psList();
				await Promise.all(processes.map(async ps => {
					if (ps.name === 'node' && ps.pid !== process.pid) {
						await kill(ps.pid, options);

process-exists

Check if a process is running

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular process-exists functions