How to use ps-tree - 10 common examples

To help you get started, we’ve selected a few ps-tree 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 aragon / aragon-cli / packages / e2e-tests / src / util.js View on Github external
new Promise((resolve, reject) => {
        psTree(subprocess.pid, (err, children) => {
          if (err) reject(err)

          children.map(child => {
            // each child has the properties: COMMAND, PPID, PID, STAT
            logger(logPrefix, 'killing child: ', child)
            process.kill(child.PID, killSignal)
          })

          resolve()
        })
      })
github NebulousLabs / Sia-UI / test / app.js View on Github external
const pkillSiad = () => new Promise((resolve, reject) => {
	psTree(process.pid, (err, children) => {
		if (err) {
			reject(err)
		}
		children.forEach((child) => {
			const commString = child.COMM ? 'COMM' : 'COMMAND'
			if (child[commString].includes('siad') || child[commString].includes('siad.exe')) {
				if (process.platform === 'win32') {
					spawn('taskkill', ['/pid', child.PID, '/f', '/t'])
				} else {
					try {
						process.kill(child.PID, 'SIGKILL')
					} catch (e) {
						console.log('Error SIGKILL', e)
					}
				}
			}
github NebulousLabs / Sia-UI / test / app.js View on Github external
const getSiadChild = (pid) => new Promise((resolve, reject) => {
	psTree(pid, (err, children) => {
		if (err) {
			reject(err)
		}
		children.forEach((child) => {
			const commString = child.COMM ? 'COMM' : 'COMMAND'
			if (child[commString].includes('siad') || child[commString].includes('siad.exe')) {
				resolve({exists: true, pid: child.PID})
			}
		})
		resolve({exists: false})
	})
})
github machawk1 / wail / wail-core / managers / serviceManager / processControlers / waybackProcessController.js View on Github external
return new Promise((resolve, reject) => {
      if (process.platform !== 'win32') {
        psTree(this.process.pid, (err, kids) => {
          if (err) {
            console.error('ps tree error', err)
            reject(new pcErrors.KillServiceError('waybak', 'psTree', err))
          } else {
            if (kids.length > 0) {
              let dukeNukem = cp.spawn('kill', ['-9'].concat(kids.map(p => p.PID)), {
                shell: true,
                stdio: ['ignore', 'ignore', 'ignore']
              })
              dukeNukem.unref()
              let bail = setTimeout(() => {
                reject(new pcErrors.FailedToKillServiceTimeoutError('waybak', 'kill -9 pid'))
              }, 10000)
              this.on('wayback-restart-exit', (code) => {
                clearTimeout(bail)
                console.log('we have the restart exit', code)
github machawk1 / wail / wail-core / util / serviceManHelpers.js View on Github external
const killPid = pid => new Promise((resolve, reject) => {
  if (process.platform !== 'win32') {
    psTree(pid, (err, kids) => {
      if (err) {
        console.error('ps tree error', err)
        process.kill(pid, 'SIGTERM')
      } else {
        if (kids.length > 0) {
          let dukeNukem = cp.spawn('kill', ['-9'].concat(kids.map(p => p.PID)), {
            shell: true,
            stdio: ['ignore', 'ignore', 'ignore']
          })
          dukeNukem.on('exit', () => {
            resolve()
          })
        } else {
          process.kill(pid, 'SIGTERM')
          resolve()
        }
github machawk1 / wail / wail-core / managers / serviceManager / processControlers / heritrixProcessController.js View on Github external
return new Promise((resolve, reject) => {
      if (process.platform !== 'win32') {
        psTree(this.process.pid, (err, kids) => {
          if (err) {
            console.error('ps tree error', err)
            reject(new pcErrors.KillServiceError('heritrix', 'psTree', err))
          } else {
            if (kids.length > 0) {
              let dukeNukem = cp.spawn('kill', ['-9'].concat(kids.map(p => p.PID)), {
                shell: true,
                stdio: ['ignore', 'ignore', 'ignore']
              })
              dukeNukem.on('exit', () => {
                resolve()
              })
            } else {
              process.kill(this.process.pid, 'SIGTERM')
              resolve()
            }
github alex-saunders / glicky / src / server / eventHandlers / processes / processManager.js View on Github external
return new Promise((resolve, reject) => {
      if (killTree) {
        psTree(this.pid, (err, children) => {
          [this.pid].concat(children.map(p => p.PID)).forEach(tpid => {
            try {
              process.kill(tpid, signal);
            } catch (ex) {
              reject(this.emitError(ex));
            }
          });
          resolve();
        });
      } else {
        try {
          process.kill(this.pid, signal);
        } catch (ex) {
          reject(ex);
        }
        resolve();
github samueleaton / screwy / src / scripts / processQueue.js View on Github external
function terminate(pid, cb) {
	psTree(pid, (err, children) => {
		spawn('kill', ['-9'].concat(children.map(p => p.PID)));
		if (typeof cb === 'function') return cb(err);
	});
}
github uditalias / swamp / lib / objects / swampService.js View on Github external
_killProcess: function (signal) {

        if (this.process) {

            Q.denodeify(psTree.bind(psTree))(this.pid)
                .then(this._onProcessTree.bind(this))

            this.process.kill(signal || this._stopSignal);
        }

    },

ps-tree

Get all children of a pid

MIT
Latest version published 6 years ago

Package Health Score

73 / 100
Full package analysis

Popular ps-tree functions

Similar packages