Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/process-exists
Check if a process is running
https://github.com/sindresorhus/process-exists
Last synced: 6 days ago
JSON representation
Check if a process is running
- Host: GitHub
- URL: https://github.com/sindresorhus/process-exists
- Owner: sindresorhus
- License: mit
- Created: 2015-06-20T18:13:25.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2021-11-04T13:53:36.000Z (about 3 years ago)
- Last Synced: 2025-01-11T23:33:41.144Z (14 days ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 58
- Watchers: 7
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-cross-platform-nodejs - process-exists - Check if a process exists. (Libraries / Processes)
README
# process-exists
> Check if a process is running
## Install
```sh
npm install process-exists
```## Usage
```js
import {processExists, processExistsMultiple, filterExistingProcesses} from 'process-exists';console.log(await processExists(process.pid));
//=> trueconst exists = await processExistsMultiple([process.pid, 'foo']);
console.log(exists.get(process.pid));
//=> trueconsole.log(exists.get('foo'));
//=> falseconsole.log(filterExistingProcesses(exists));
//=> [process.pid]
```## API
### processExists(input)
Check if a process exists.
Returns a `Promise`.
#### input
Type: `number | string`
The process ID or name to check.
### processExistsMultiple(input)
Check multiple processes if they exist.
Returns a `Promise` with the process name/ID as key and the status as a boolean value.
#### input
Type: `Array`
The process IDs or names to check.
### filterExistingProcesses(input)
Filter processes that exist.
Returns an `Array` with the processes that exist.
#### input
Type: `Array`
The process IDs or names to check.