Split source into multiple files
SIGUSR1 now causes reload of blacklist sigstoped now resumes all processes it stoped upon reciving SIGINT or SIGTERM sigstoped avoids stopping processes that have no top level window left TODO: is this enough?
This commit is contained in:
parent
3c7d0f49de
commit
569ce05dbb
8 changed files with 389 additions and 219 deletions
47
process.cpp
Normal file
47
process.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "process.h"
|
||||
#include "split.h"
|
||||
|
||||
bool Process::operator==(const Process& in)
|
||||
{
|
||||
return pid == in.pid;
|
||||
}
|
||||
|
||||
bool Process::operator!=(const Process& in)
|
||||
{
|
||||
return pid != in.pid;
|
||||
}
|
||||
|
||||
Process::Process(pid_t pidIn)
|
||||
{
|
||||
if(pidIn > 0)
|
||||
{
|
||||
std::fstream statusFile;
|
||||
std::string statusString;
|
||||
statusFile.open(std::string("/proc/") + std::to_string(pidIn)+ "/status", std::fstream::in);
|
||||
if(statusFile.is_open())
|
||||
{
|
||||
std::string statusString((std::istreambuf_iterator<char>(statusFile)),
|
||||
std::istreambuf_iterator<char>());
|
||||
std::vector<std::string> lines = split(statusString);
|
||||
if(lines.size() > 0)
|
||||
{
|
||||
pid = pidIn;
|
||||
std::vector<std::string> tokens = split(lines[0], '\t');
|
||||
if(tokens.size() > 1)
|
||||
{
|
||||
name = tokens[1];
|
||||
}
|
||||
}
|
||||
statusFile.close();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"cant open "<<"/proc/" + std::to_string(pidIn)+ "/status"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue