mirror of
https://github.com/diamante0018/MonitorRam.git
synced 2025-06-27 14:51:50 +00:00
Re-ordering
This commit is contained in:
20
monitor.c
20
monitor.c
@ -68,7 +68,17 @@ void isProcessWild(int currRealMem, int peakRealMem,
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Logs to a file in case something is up
|
||||
|
||||
// Sends a polite request to terminate
|
||||
printf("Terminating process: %d. Too much memory!\n", ID);
|
||||
int result = kill(ID, SIGTERM);
|
||||
if (result)
|
||||
{
|
||||
printf("Error while terminating process: %d\n", ID);
|
||||
printf("Error message: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
// Logs
|
||||
FILE *fp;
|
||||
fp = fopen("Diavolo.txt", "a");
|
||||
if (fp == NULL)
|
||||
@ -81,14 +91,6 @@ void isProcessWild(int currRealMem, int peakRealMem,
|
||||
fprintf(fp, "WARNING: Exceeded %d KiB of Real Memory for process ID: %d\n", MAX_MEMORY, ID);
|
||||
fprintf(fp, "Process ID: %d\ncurrRealMem:%d KiB\npeakRealMem:%d KiB\ncurrVirtMem:%d KiB\npeakVirtMem:%d KiB\n", ID, currRealMem, peakRealMem, currVirtMem, peakVirtMem);
|
||||
fclose(fp);
|
||||
// Sends a polite request to terminate
|
||||
printf("Terminating process: %d. Too much memory!\n", ID);
|
||||
int result = kill(ID, SIGTERM);
|
||||
if (result)
|
||||
{
|
||||
printf("Error while terminating process: %d\n", ID);
|
||||
printf("Error message: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static int processID[MAX_TRACK_SIZE] = {0};
|
||||
|
Reference in New Issue
Block a user