View topic - SIGCONT handling in QNX 6.4.1 and 6.2.0

SIGCONT handling in QNX 6.4.1 and 6.2.0

Discussion about the general applications that run on QNX6

SIGCONT handling in QNX 6.4.1 and 6.2.0

Postby sarwan_007 » Wed Aug 26, 2009 2:33 pm

SIGCONT signal has been handled in QNX 6.4.1 but not in QNX 6.2.0 for a same code. Can anyone tell me the reason.
The code is here

include <iostream>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>

using namespace std;
//variable used to calculate the time stamp
const double dTwoPower32 = 4.0 * (double)(1<<30);

// time stamp value
long int uiTop = 0;
long int uiBottom = 0;
double dPRUDBStart = 0;
double dPRUDBEnd = 0;
double dClockSpeed = 850000000; // Hz

#define mGetTimeStamp() __asm( "push %eax\n"\
"push %edx\n"\
"rdtsc\n"\
"mov %edx, uiTop\n"\
"mov %eax, uiBottom\n"\
"pop %edx\n"\
"pop %eax\n")

// ****************************************************************************
// Member Function: mGetTimeStampInSeconds
// Description: Returns the number of seconds elapsed from system powerup
//
// ****************************************************************************
double mGetTimeStampInSeconds( void )
{

mGetTimeStamp();

return( ((double)uiBottom
+ (double)uiTop * dTwoPower32)
/ dClockSpeed);
}

// ****************************************************************************
// Member Function: mGetTimeStampInMilliSeconds
// Description: Returns the number of milli seconds elapsed from
// system powerup
// ****************************************************************************
double mGetTimeStampInMilliSeconds( void )
{

return( mGetTimeStampInSeconds() * 1000.0 );
}

// ****************************************************************************
// Function : mGenericSignalHandler
// Description : This function handles thegenerated signal
// ****************************************************************************
void mGenericSignalHandler( int nSignal )
{
printf("\n\n mGenericSignalHandler called ");
printf("\n\nSignal is: %d ", nSignal);
switch (nSignal)
{
case SIGINT:
{
printf("\nReceived Signal: %d:SIGINT. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);
exit(nSignal);

}break;
case SIGQUIT:
{
printf("\nReceived Signal: %d:SIGQUIT. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGILL:
{
printf("\nReceived Signal: %d:SIGILL. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

}break;
case SIGTRAP:
{
printf("\nReceived Signal: %d:SIGTRAP. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

}break;
case SIGABRT:
{
printf("\nReceived Signal: %d:SIGABRT. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGFPE:
{
printf("\nReceived Signal: %d:SIGFPE. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGBUS:
{
printf("\nReceived Signal: %d:SIGBUS. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

}break;
case SIGSEGV:
{
printf("\nReceived Signal: %d:SIGSEGV. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGPIPE:
{
printf("\nReceived Signal: %d:SIGPIPE. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGPWR:
{
printf("\nReceived Signal: %d:SIGPWR. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGHUP:
{
printf("\nReceived Signal: %d:SIGHUP. Signal handled", nSignal);
dPRUDBEnd= mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGEMT:
{
printf("\nReceived Signal: %d:SIGEMT. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGSYS:
{
printf("\nReceived Signal: %d:SIGSYS. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGALRM:
{
printf("\nReceived Signal: %d:SIGALRM. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGTERM:
{
printf("\nReceived Signal: %d:SIGTERM. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGUSR1:
{
printf("\nReceived Signal: %d:SIGUSR1. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGUSR2:
{
printf("\nReceived Signal: %d:SIGUSR2. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGCHLD:
{
printf("\nReceived Signal: %d:SIGCHLD. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGWINCH:
{
printf("\nReceived Signal: %d:SIGWINCH. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGURG:
{
printf("\nReceived Signal: %d:SIGURG. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
//similar to SIGIO signal
/* case SIGPOLL:
{
printf("\nReceived Signal: %d. Signal handled", nSignal);
}break;*/
case SIGIO:
{
printf("\nReceived Signal: %d:SIGIO/SIGPOLL. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGSTOP:
{
printf("\nReceived Signal: %d:SIGSTOP. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGTSTP:
{
printf("\nReceived Signal: %d:SIGTSTP. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGCONT:
{
printf("\nReceived Signal: %d:SIGCONT. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGTTIN:
{
printf("\nReceived Signal: %d:SIGTTIN. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms\n ",dPRUDBEnd -dPRUDBStart);

} break;
case SIGTTOU:
{
printf("\nReceived Signal: %d:SIGTTOU. Signal handled", nSignal);
dPRUDBEnd = mGetTimeStampInMilliSeconds();
printf("\n TIME TAKEN TO RECEIVE THE SIGNAL :%lf ms \n ",dPRUDBEnd -dPRUDBStart);

} break;

default:
{
printf("\nINVALID");

} break;
}

}


// ****************************************************************************
// Function : mGenericSignalRegister
// Description : This function registers the signal
// ****************************************************************************
void mGenericSignalRegister( )
{
// SIGHUP = 1 process hangup
(void)signal(SIGHUP, mGenericSignalHandler);

// SIGINT = 2 interrupt, which can be given through ctrl+c
(void)signal(SIGINT, mGenericSignalHandler);

// SIGQUIT = 3 quit
(void)signal(SIGQUIT, mGenericSignalHandler);

// SIGILL = 4 illegal instruction (not reset when caught)
(void)signal(SIGILL, mGenericSignalHandler);

// SIGTRAP = 5 trace trap (not reset when caught)
(void)signal(SIGTRAP, mGenericSignalHandler);

// SIGABRT = 6 used by abort
(void)signal(SIGABRT, mGenericSignalHandler);

// SIGEMT = 7 EMT instruction
(void)signal(SIGEMT, mGenericSignalHandler);

// SIGFPE = 8 floating point exception
(void)signal(SIGFPE, mGenericSignalHandler);

// SIGBUS = 10 bus error
(void)signal(SIGBUS, mGenericSignalHandler);

// SIGSEGV = 11 segmentation violation
(void)signal(SIGSEGV, mGenericSignalHandler);

// SIGSYS = 12 bad argument to system call
(void)signal(SIGSYS, mGenericSignalHandler);

// SIGPIPE = 13 write on pipe with no reader
(void)signal(SIGPIPE, mGenericSignalHandler);

// SIGALRM = 14 real-time alarm clock
(void)signal(SIGALRM, mGenericSignalHandler);

// SIGTERM = 15 software termination signal from kill
(void)signal(SIGTERM, mGenericSignalHandler);

// SIGUSR1 = 16 user defined signal 1. Used by base utilites to raise
(void)signal(SIGUSR1, mGenericSignalHandler);

// SIGUSR2 = 17 user defined signal 2
(void)signal(SIGUSR2, mGenericSignalHandler);

// SIGCHLD = 18 death of child
(void)signal(SIGCHLD, mGenericSignalHandler);

// SIGPWR = 19 power-fail restart
(void)signal(SIGPWR, mGenericSignalHandler);

// SIGWINCH = 20 window change
(void)signal(SIGWINCH, mGenericSignalHandler);

// SIGURG = 21 urgent condition on I/O channel
(void)signal(SIGURG, mGenericSignalHandler);

// SIGIO = 22 System V name for SIGIO
(void)signal(SIGPOLL, mGenericSignalHandler);

// SIGIO = 22 Asynchronus I/O
(void)signal(SIGIO, mGenericSignalHandler);

// SIGSTOP = 23 sendable stop signal not from tty
(void)signal(SIGSTOP, mGenericSignalHandler);

// SIGTSTP = 24 stop signal from tty
(void)signal(SIGTSTP, mGenericSignalHandler);

// SIGCONT = 25 continue a stopped process
(void)signal(SIGCONT, mGenericSignalHandler);

// SIGTTIN = 26 attempted background tty read
(void)signal(SIGTTIN, mGenericSignalHandler);

// SIGTTOU = 27 attempted background tty write
(void)signal(SIGTTOU, mGenericSignalHandler);
}


// ****************************************************************************
// Function : mGenerateSignal
// Description : This function is used to generate the signal using raise QNX call
// ****************************************************************************
void mGenerateSignal( )
{
int nOpt = NULL;

printf("\n1. process hangup");
printf("\n2. interrupt, which can be given through ctrl+c");
printf("\n3. quit");
printf("\n4. illegal instruction (not reset when caught)");
printf("\n5. trace trap (not reset when caught");
printf("\n6. used by abort ");
printf("\n7. EMT instruction");
printf("\n8. floating point exception");
printf("\n9. bus error");
printf("\n10. Generating Signal 11");
printf("\n11. bad argument to system call");
printf("\n12.write on pipe with no reader");
printf("\n13. real-time alarm clock");
printf("\n14. software termination signal from kill ");
printf("\n15. user defined signal 1. Used by base utilities to raise");
printf("\n16. user defined signal 2");
printf("\n17. death of child");
printf("\n18. power-fail restart");
printf("\n19. window change ");
printf("\n20. urgent condition on I/O channel");
printf("\n21. System V name for SIGIO");
printf("\n22. Asynchronous I/O");
printf("\n23. send able stop signal not from tty");
printf("\n24. stop signal from tty ");
printf("\n25. continue a stopped process");
printf("\n26. attempted background tty read");
printf("\n27. attempted background tty write");
cout<<"\n\nEnter Your Choice:";
cin>>nOpt;
//printf("\n\nEnter Your Choice");
//scanf("%d",&nOpt);


switch( nOpt )
{

case 1:
{
//process hangup
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGHUP );

}
break;
case 2:
{
//interrupt, which can be given through ctrl+c
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGINT );
}
break;
case 3:
{
//quit
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGQUIT );
}
break;
case 4:
{
//illegal instruction (not reset when caught)
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGILL );
}
break;
case 5:
{
//trace trap (not reset when caught)
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGTRAP );
}
break;
case 6:
{
//used by abort
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGABRT );

}
break;
case 7:
{
//EMT instruction
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGEMT );
}
break;
case 8:
{
//floating point exception
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGFPE );

}
break;
case 9:
{
// bus error
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGBUS );
}
break;
case 10:
{
//Generating Signal 11
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGSEGV );
}
break;
case 11:
{
//bad argument to system call
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGSYS );
}
break;
case 12:
{
//write on pipe with no reader
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGPIPE );
}
break;
case 13:
{
//real-time alarm clock
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGALRM );
}
break;
case 14:
{
//software termination signal from kill
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGTERM );
}
break;
case 15:
{
//user defined signal 1. Used by base utilites to raise
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGUSR1 );
}
break;
case 16:
{
//user defined signal 2
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGUSR2 );
}
break;
case 17:
{
//death of child
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGCHLD );
}
break;
case 18:
{
//power-fail restart
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGPWR );
}
break;
case 19:
{
//window change
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGWINCH );
}
break;
case 20:
{
//urgent condition on I/O channel
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGURG );
}
break;
case 21:
{
//System V name for SIGIO
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGPOLL );
}
break;
case 22:
{
//Asynchronus I/O
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGIO );
}
break;
case 23:
{
//sendable stop signal not from tty
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGSTOP );
}
break;
case 24:
{
// stop signal from tty
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGTSTP );
}
break;
case 25:
{
// continue a stopped process
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGCONT );
}
break;
case 26:
{
// attempted background tty read
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGTTIN );
}
break;
case 27:
{
// attempted background tty write
dPRUDBStart = mGetTimeStampInMilliSeconds();
raise( SIGTTOU );
}
break;

default:
{
printf("Invalid option");
}
break;
}

}
// ****************************************************************************
// Function : main
// Description : MAIN FUNCTION
// ****************************************************************************
int main(void)
{
//function call to register all signals
mGenericSignalRegister( );
while(1)
{
//function call to generate the signals
mGenerateSignal();
}
return(NULL);
}
sarwan_007
Active Member
 
Posts: 10
Joined: Mon Jul 06, 2009 9:59 am

Postby Tim » Wed Aug 26, 2009 5:08 pm

Sarwan,

According to my 6.3.0 documentation (see slay) SIGCONT isn't delivered to a process/thread unless its in the SIGSTOP state. So you'll have to put your program in the SIGSTOP state in order to receive the SIGCONT signal.

If you are receiving it 6.4.1 without being SIGSTOPed it means it must have changed in 6.4. You can probably review the docs for slay to see if it mentions this.

Tim
Tim
Senior Member
 
Posts: 1503
Joined: Wed Mar 10, 2004 12:28 am


Return to QNX6 - Applications

Who is online

Users browsing this forum: No registered users and 1 guest

cron