Refactoring

This commit is contained in:
2022-01-26 16:24:09 +01:00
parent 551ff95660
commit 9b0dc4d21b
12 changed files with 5268 additions and 84 deletions

View File

@@ -3,6 +3,11 @@ const fs = require('fs');
const net = require('net');
const { logger } = require('./logger');
/**
* Browse /proc in order to find the specific pid
* @param {number} pid
* @returns {*} process stats if any
*/
function existsInProc(pid) {
try {
return fs.statSync(`/proc/${pid}`)
@@ -24,6 +29,10 @@ function retriveStdoutFromProcFd(pid) {
}
*/
/**
* Kills a process with a sys-call
* @param {number} pid the killed process pid
*/
async function killProcess(pid) {
const res = spawn('kill', [pid])
res.on('exit', () => {