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
sigaction(3)						     Library Functions Manual						      sigaction(3)

Name
       sigaction - software signal facilities (POSIX)

Syntax
       #include <signal.h>

       struct sigaction {
       void  (*sa_handler)();
       sigset_t sa_mask;
       int   sa_flags;
       };

       int sigaction(sig, vec, ovec)
       int sig;
       struct sigaction *vec, *ovec;

Description
       The sigaction call is the POSIX equivalent to the system call. This call behaves as described on the reference page with the following mod-
       ifications:

       o    The signal mask is manipulated using the functions.

       o    A process can suppress the generation of the SIGCHLD when a child stops by setting the SA_NOCLDSTOP bit in sa_flags.

       o    The SV_INTERRUPT flag is always set by the system when using in POSIX mode. The flag is set so that interrupted system calls will fail
	    with the EINTR error instead of getting restarted.

Return Values
       A  0  return value indicated that the call succeeded.  A -1 return value indicates an error occurred and errno is set to indicated the rea-
       son.

Diagnostics
       The system call fails and a new signal handler is not installed if one of the following occurs:

       [EFAULT]       Either vec or ovec points to memory which is not a valid part of the process address space.

       [EINVAL]       Sig is not a valid signal number.

       [EINVAL]       An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP.

See Also
       sigvec(2), sigsetops(3), sigprocmask(3), sigsuspend(3), sigpending(2), setjmp(3), siginterrupt(3), tty(4)

																      sigaction(3)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy