Sponsored Content
Top Forums Programming Handling a signal with a class member function Post 302292250 by Zipi on Friday 27th of February 2009 08:52:05 AM
Old 02-27-2009
Handling a signal with a class member function

Hello,
i am using the sigaction function to handle the SIGCHLD signal.Is it possible to use a class member function as the handler function (the sa_handler member of the sigaction structure)?
The function's signature is:
Code:
void (*sa_handler)(int);

so i don't think i can use a static member function to call the actual handler function.

Any idea?
Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Programming

Signal Handling

Hi folks I'm trying to write a signal handler (in c on HPUX) that will catch the child process launched by execl when it's finished so that I can check a compliance file. The signal handler appears to catch the child process terminating however when the signal handler completes the parent... (3 Replies)
Discussion started by: themezzaman
3 Replies

2. Shell Programming and Scripting

Signal handling in Perl

Guys, I'm doing signal handling in Perl. I'm trying to catch ^C signal inside the script. There two scripts : one shell script and one perl script. The shell script calls the perl script. For e.g. shell script a.sh and perl scipt sig.pl. Shell script a.sh looks something like this :... (6 Replies)
Discussion started by: obelix
6 Replies

3. Programming

signal handling question

Hello all, I am starting to learn signal handling in Linux and have been trying out some simple codes to deal with SIGALRM. The code shown below sets a timer to count down. When the timer is finished a SIGALRM is produced. The handler for the signal just increments a variable called count. This... (7 Replies)
Discussion started by: fox_hound_33
7 Replies

4. Programming

signal handling while in a function other than main

Hi, I have a main loop which calls a sub loop, which finally returns to the main loop itself. The main loop runs when a flag is set. Now, I have a signal handler for SIGINT, which resets the flag and thus stops the main loop. Suppose I send SIGINT while the program is in subloop, I get an error... (1 Reply)
Discussion started by: Theju
1 Replies

5. Programming

Signal handling

I am trying to write a small program where I can send signals and then ask for an action to be triggered if that signal is received. For example, here is an example where I am trying to write a programme that will say you pressed ctrl*c when someone presses ctrl+c. My questions are what you would... (1 Reply)
Discussion started by: #moveon
1 Replies

6. UNIX and Linux Applications

SIGSEGV Signal handling

Hello, Can anybody tell me how can i handle segmentation fault signal, in C code? (2 Replies)
Discussion started by: mustus
2 Replies

7. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

8. Programming

Writing C++ class and member functions

I have the following class and thought that when I call the set command to set a member, I always use value. Would that be fine? class ModMisfit { protected: Real dtau; Real mdacc; Real mindist; bool hw; Source** src; public: void ... (7 Replies)
Discussion started by: kristinu
7 Replies

9. Programming

Restricting member of a class non-inheritable in C++

There is base class B, and two derived classes D1 and D2 derived from Base. Base class B, have two data members ( public or protected or private or if any). D1 should inherit both these data members, and D2 should be deriving only one member from Base class. Is this kind of design possible without... (1 Reply)
Discussion started by: techmonk
1 Replies

10. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies
sigvec(2)							System Calls Manual							 sigvec(2)

NAME
sigvec - Provides a compatibility interface to the sigaction() function SYNOPSIS
#include <sys/signal.h> int sigvec ( int signal, struct sigvec *in_vec, struct sigvec *out_vec ); PARAMETERS
Specifies the signal number. Points to a sigvec() structure that specifies the action to be taken when the specified signal is delivered, the mask to be used when calling the signal handler, and the flags that modify signal behavior. Points to a sigvec() structure that is set to the previous signal action state on successful return from the sigvec() function. DESCRIPTION
The sigvec() function is provided for compatibility to old UNIX systems; its function is a subset of that available with the sigaction() function. Like the sigaction() function, the sigvec() function allows the user to set the action to take upon the receipt of a signal and to specify a signal handler mask to block signals before calling the signal handler. However, only signals with values 1 to 31 can be masked on entry to a signal-handler set up with the sigvec() function. The sigvec() structure has the following members: void (*sv_handler)( ); int sv_mask; int sv_flags; The sv_handler field specifies the action for the signal, and can be SIG_DFL, SIG_IGN, or the address of a signal handler function. See the sigaction() function for a detailed description of the signal actions. The sv_mask field specifies a mask which specifies signals to block (in addition to any signals already blocked at time of delivery) when the signal handler function is called for the signal. Signal i is blocked if the i-th bit of the mask is set. Only signals with values 1 to 31 can be masked with the sigvec() function. The sv_flags field contains flags that further specify signal behavior. If SV_ONSTACK is set, the signal handler runs on the signal stack specified by the sigstack() function; otherwise, the signal handler runs on the stack of the process receiving the signal. If SV_INTERRUPT is set, a system call that is interrupted by signal returns a value of -1 with errno set to [EINTR]; otherwise, a system call interrupted by signal is restarted. If the value of the in_vec parameter is a null pointer, then the signal handler information is not set. If the value of the out_vec parame- ter is null, then the previous signal handler information is not returned. Once a signal handler is assigned, it remains assigned until another call to the sigvec(), signal(), sigaction(), or exec function is made. NOTES
The sigvec() function is provided for compatibility only, and its use is not recommended. Programs should use the sigaction() function instead. The sigvec() function does not check the validity of the sv_handler field pointer. If it points to a location outside of the process address space, the process receives a memory fault when the system attempts to call the signal handler. If the sv_handler field points to anything other than a function, the results are unpredictable. The signal-handler function can be declared as follows: void handler ( int signal ); RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the sigvec() function fails, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the sigvec() function fails, no new signal handler is installed and errno may be set to one of the following values: The in_vec or out_vec parameter points to a location outside of the process' address space. The signal parameter is not a valid signal number. An attempt was made to ignore or supply a handler for the SIGKILL signal. RELATED INFORMATION
Functions: kill(2), ptrace(2), sigaction(2), sigblock(2), sigpause(3), sigstack(2) delim off sigvec(2)
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy