48 ERROR(
"Cannot start process");
49 throw std::runtime_error (
"Async error");
90 const std::vector<std::string>& args):
98 c_args[0] =
const_cast<char*
> (program.c_str());
99 for (
unsigned int i = 0; i < args.size(); ++i){
100 c_args[i+1] =
const_cast<char*
> (args[i].c_str());
102 c_args[args.size()+1] = (
char*) NULL;
104 execvp(program.c_str(), c_args);
177 if (kill(
pid_, sig) != 0){
178 ERROR(
"Can't send signal " << sig);
204 sigset_t oldset,
set;
208 sigprocmask(SIG_SETMASK, &
set, &oldset);
209 bzero( &sa,
sizeof(sa) );
210 sa.sa_handler = handler;
211 if (sigaction(sig, &sa, NULL) < 0) {
212 ERROR(
"Can't set signal " << sig);
216 sigprocmask(SIG_SETMASK, &oldset,NULL);
231 struct sched_param p;
232 p.sched_priority = priority;
233 if (sched_setscheduler(
pid_, policy, &p) == 0)
251 struct sched_param p;
252 int ret = sched_getparam(
pid_, &p);
253 *priority = p.sched_priority;
254 *policy = sched_getscheduler(
pid_);
255 if ((*policy < 0) || (ret < 0))
262 #if defined(ONPOSIX_LINUX_SPECIFIC) && defined(__GLIBC__) && \
263 ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ > 3)))
277 void Process::setAffinity(
const std::vector<bool>& v)
281 for (
unsigned int i = 0; (i < v.size()) && (i < CPU_SETSIZE); ++i)
285 if ((sched_setaffinity(
pid_,
sizeof(s), &s) != 0))
286 throw std::runtime_error (
"Set affinity error");
301 void Process::getAffinity(std::vector<bool>* v)
306 if ((sched_getaffinity(
pid_,
sizeof(s), &s) != 0))
307 throw std::runtime_error (
"Get affinity error");
309 for (
unsigned int j = 0; (j < CPU_SETSIZE) && (j < v->size()); ++j) {
310 if (CPU_ISSET(j, &s))