8ecc c++ limit process child ignore SIGXCPU - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old May 1st, 2012, 14:45
xnl96 xnl96 is offline
Junior Member
 
Join Date: Mar 2009
Posts: 48
Thanks: 8
Thanked 2 Times in 2 Posts
Default 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?

Last edited by DutchDaemon; May 1st, 2012 at 17:56.
Reply With Quote
  #2  
Old May 1st, 2012, 20:19
anon12b anon12b is offline
Junior Member
 
Join Date: Apr 2012
Posts: 17
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] c++ limit process xnl96 Userland Programming & Scripting 2 December 22nd, 2011 21:20
Anyone? Gnome terminal: error creating the child process mdg583 GNOME 2 September 6th, 2009 12:40
max one 'fat' allowed as child of 'whole' ororo Installing & Upgrading 13 June 3rd, 2009 19:12
bce0 : /usr/src/sys/dev/bce/if_bce.c(1044): No PHY found on Child MII bus celica013 Networking 8 June 1st, 2009 17:01
[Solved] perl: how to start child process in background? graudeejs Userland Programming & Scripting 4 March 26th, 2009 11:33


All times are GMT +1. The time now is 11:52.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0