- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Catching signals sent by OS to the process
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 08:24 PM
10-28-2003 08:24 PM
Catching signals sent by OS to the process
I want to execute some code when a SIGSEGV/SIGBUS is sent by OS to my process.
I have written the attached code(gencatchsignal.C) to do this:
I compile it using aCC on HP-UX 11i as:
aCC -g gencatchsignal.C -lpthread
The line 33: "*str_tok_end = '\0';" generates a SIGBUS error.
But the application immediately dumps the core.
I had expected that the function: Signalhandler_SIGBUS which is configured to handle SIGBUS should get invoked.
Can anyone please suggest a way for me to handle this SIGBUS signal.
Regards,
Shashibhushan Gokhale
***********************************************
PS:
Actually I want to implement this for a SIGSEGV, but am facing the following problem. I understand that if I generate SIGSEGV using the following code snippet(which I got from Elmar in response to my earlier question):
int main(int argc, char** argv)
{ int i;
for (i =0; ; i++)
argv[1] = argv[i];
}
The system stack gets exhausted and hence SignalHandler cannot be loaded.
Hence have taken this example of SIGBUS.
It would be fantastic if someone can generate and then catch a SIGSEGV(The function SignalHandler_SIGSEGV should get called) in my program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 09:20 PM
10-28-2003 09:20 PM
Re: Catching signals sent by OS to the process
ie if you copy the 2 calls to
signal(SIGBUS,SignalHandler_SIGBUS) ;
signal(SIGSEGV,SignalHandler_SIGSEGV) ;
to the first executable lines of main(), then you will arm the signal handlers in time and the signal will be trapped.
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 09:20 PM
10-28-2003 09:20 PM
Re: Catching signals sent by OS to the process
At first I tried setting the signal function calls before creating the pthread, but that is not necessary. But perhaps it is in your aCC to make sure that this is set before you generate the signal. I am not sure if the interupthandler is called before the thread is started, you see.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 10:12 PM
10-28-2003 10:12 PM
Re: Catching signals sent by OS to the process
Let me compensate for my previous response.
Attached is the file. This is for SIGSEGV. Uncomment the other half for SIGBUS.
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 11:38 PM
10-28-2003 11:38 PM
Re: Catching signals sent by OS to the process
with warnings (ignorable)
Warning 829: "sign.c", line 29 # Implicit conversion of string literal to
'char *' is deprecated.
txt_ErrMsg = "TEST DATA";
^^^^^^^^^^^
Warning 829: "sign.c", line 15 # Implicit conversion of string literal to
'char *' is deprecated.
char *name="SHASHI";
^^^^^^^^
Warning 361: "sign.c", line 37 # Value-returning function might end without
executing a return statement.
void* interruptHandler(void*)
executable fails with pthread_create failed with error code:251Exiting...
....didn't check libc,pthread,aCC patches.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2003 04:11 PM
11-08-2003 04:11 PM
Re: Catching signals sent by OS to the process
I've not used pthread see if its ok with you,
==============================
#include
#include
#include
#include
void hndl_sgnl(int);
int main(int argc,char **argv)
{
signal(SIGSEGV,hndl_sgnl);
for (int i =0;i < 40 ; i++)
{
argv[1] = *(argv + i);
printf("\n %s\n",argv[1]);
}
printf("\n Oops ! Didn't do it \n");
return 0;
}
void hndl_sgnl(int sgnl)
{
printf("\n Recvd <%d> signal\n",sgnl);
printf("\n Carry out cleaning activity and then exit\n");
exit(-1);
}
===================================