Sponsored Content
Full Discussion: Regarding stack analysis
Top Forums Programming Regarding stack analysis Post 302208042 by vpraveen84 on Sunday 22nd of June 2008 07:48:43 PM
Old 06-22-2008
Regarding stack analysis

I would like to know how I could do the following :

Code:
void func(){
  int a = 100; b=0;
  int c = a/b;
}

void sig_handler (int sig,siginfo_t *info,void *context){
//signal handling function
//here I want to access the variables of func() 
}
  
int main(){
  struct sigaction *act = (struct sigaction *)malloc(sizeof(struct sigaction));
  act->sa_flags = SA_SIGINFO;
  act->sa_sigaction = sig_handler; 
  sigaction(SIGFPE,act,NULL); 
  func();
}

As expected, this program should give an exception. But I use sigaction to catch the signal (arithmetric exception) and send control to another function(sig_handler), where I want to handle this signal.

I would like to access the variables inside func() and modify them. How can I do this ?

thank you,

Last edited by vpraveen84; 06-22-2008 at 10:54 PM..
 

6 More Discussions You Might Find Interesting

1. Solaris

Catalina Analysis

How can I make analysis for catalina.out (2 Replies)
Discussion started by: Burhan
2 Replies

2. Programming

what is stack winding and stack unwinding

helo can u tell me what do you mean by stack winding and stack unwinding Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies

3. Shell Programming and Scripting

Metacharacters analysis

:confused:Hi , Can someone please advise what is the meaning of metacharacters in below code? a_PROCESS=${0##*/} a_DPFX=${a_PROCESS%.*} a_LPFX="a_DPFX : $$ : " a_UPFX="Usage: $a_PROCESS" Regards, gehlnar (3 Replies)
Discussion started by: gehlnar
3 Replies

4. UNIX for Dummies Questions & Answers

Text analysis

Hey Guys, Does anyone know how to count the separate amount of words in a text file? e.g the 5 and 20 Furthermore does anyone know how to convert whole numbers in decimals? Thanks (24 Replies)
Discussion started by: John0101
24 Replies

5. UNIX for Dummies Questions & Answers

Kernel Stack vs User Mode Stack

Hi, I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Discussion started by: saurabhkoar
4 Replies

6. Infrastructure Monitoring

Nmon Analysis

Dear All, I am an performance tester. Now i am working in project where we are using linux 2.6.32. Now I got an oppurtunity to learn the monitoring the server. As part of this task i need to do analysis of the Nmon report. I was completely blank in this. So please suggest me how to start... (0 Replies)
Discussion started by: iamsengu
0 Replies
BSD_SIGNAL(P)						     POSIX Programmer's Manual						     BSD_SIGNAL(P)

NAME
bsd_signal - simplified signal facilities SYNOPSIS
#include <signal.h> void (*bsd_signal(int sig, void (*func)(int)))(int); DESCRIPTION
The bsd_signal() function provides a partially compatible interface for programs written to historical system interfaces (see APPLICATION USAGE). The function call bsd_signal(sig, func) shall be equivalent to the following: void (*bsd_signal(int sig, void (*func)(int)))(int) { struct sigaction act, oact; act.sa_handler = func; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask, sig); if (sigaction(sig, &act, &oact) == -1) return(SIG_ERR); return(oact.sa_handler); } The handler function should be declared: void handler(int sig); where sig is the signal number. The behavior is undefined if func is a function that takes more than one argument, or an argument of a dif- ferent type. RETURN VALUE
Upon successful completion, bsd_signal() shall return the previous action for sig. Otherwise, SIG_ERR shall be returned and errno shall be set to indicate the error. ERRORS
Refer to sigaction() . The following sections are informative. EXAMPLES
None. APPLICATION USAGE
This function is a direct replacement for the BSD signal() function for simple applications that are installing a single-argument signal handler function. If a BSD signal handler function is being installed that expects more than one argument, the application has to be modi- fied to use sigaction(). The bsd_signal() function differs from signal() in that the SA_RESTART flag is set and the SA_RESETHAND is clear when bsd_signal() is used. The state of these flags is not specified for signal(). It is recommended that new applications use the sigaction() function. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
sigaction() , sigaddset() , sigemptyset() , signal() , the Base Definitions volume of IEEE Std 1003.1-2001, <signal.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 BSD_SIGNAL(P)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy