c++ limit process child ignore SIGXCPU

I have this code
Code:
static void sigXCPU(int pTmp){
  cout<<" .... ";
}

.....
pid_t vPid=fork(); 
  int vStat;   
  
  switch(vPid){
  case -1: perror("fork");
    exit(1);
  case 0:
    //limit on data
    struct rlimit vLimD;
    vLimD.rlim_cur = 100000; 
    vLimD.rlim_max =  1000000; 
    setrlimit(RLIMIT_DATA, &vLimD);
    //limit on cpu time
    struct rlimit vLimCPU;
    vLimCPU.rlim_cur = 1;
    vLimCPU.rlim_max = 1;
    
    execl("./p1","",NULL);    
    if(signal(SIGXCPU,sigXCPU)==SIG_ERR);
    break;
  default: 
    while(wait(&vStat)!=vPid);
    break;}

and the code for p1 is
Code:
int main(){
  sleep(10);
return 0;}
Why does the child ignore SIGXCPU?
 
If I understand your question, then the answer is because execl(3) never returns (unless in error, see the man page). The code between the execl(3) and the next case statement is not run, assuming the called program can be executed. Therefore, your call to signal(3) never happens, and, thus, your callback is never registered.
 
Back
Top