Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gtop.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function init() {
new monitor.Mem(memLine, memDonut, swapDonut);
new monitor.Net(netSpark);
new monitor.Disk(diskDonut);
new monitor.Proc(procTable); // no Windows support
new monitor.Proc(procTable, blessed, screen); // no Windows support
}


Expand Down
42 changes: 41 additions & 1 deletion lib/monitor/proc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var pars = {
m: 'pmem'
}

function Proc(table) {
function Proc(table, blessed, screen) {
this.table = table;

this.pSort = 'pcpu';
Expand Down Expand Up @@ -38,6 +38,46 @@ function Proc(table) {
updater();
});

var form;

this.table.rows.on('select', (node, index) => {
this.selectedProc = node.parent.value.match(/[0-9]+/g)[0];

form = blessed.form({
parent: screen,
width: 60,
height: 4,
keys: true,
border: {
type: 'line'
},
top: 'center',
left: 'center'
});

blessed.text({
parent: form,
fg: 'green',
content: 'Press y button to kill process #'+this.selectedProc+ ' \n Or, press n button to cancel'
});

form.on('submit', (data) => {
screen.remove(form);
process.kill(this.selectedProc, 'SIGHUP');
});

screen.render();
});

screen.key(['y'], (ch, key) => {
form.submit();
});

screen.key(['n'], (ch, key) => {
screen.remove(form);
this.selectedProc = 0;
});

}

Proc.prototype.updateData = function(data) {
Expand Down