var spawn = require('child_process').spawn;
var rootPath=process.cwd();
async function runApp() {
    const child = spawn('top');

    console.log(`Spawned child pid: ${child.pid}`);

    child.stdin.end();

    child.stdout.on('data',  (data)=> {
        console.log("" + data);
        //Here is where the output goes
    });
    child.stderr.on('data',  (data)=> {
        console.log('stderr: ' + data);
        //Here is where the error output goes
    });
    child.on('close',  async (code)=> {
        console.log('closing code: ' + code);
        //Here you can get the exit code of the script

        await runApp()
    });

}


async function updateApp(){

}


runApp();

setInterval(() => {

}, 200)