Sponsored Content
Top Forums Programming Signal Handling and Context Switches Post 302266563 by XComp on Wednesday 10th of December 2008 02:25:24 PM
Old 12-10-2008
I've isolated the source of error a little bit more. It is because of using the third parameter of the signal handler for saving the context of the thread function. If I pass the parameter context to setcontext instead of saving it in thread_context and swapping back to scheduler_context the same error will occur.
If will post an explanation of this strange behaviour to the linux kernel mailing list. Maybe they have an answer for it. I'll post the reply then.

Last edited by XComp; 12-10-2008 at 03:26 PM.. Reason: improving language
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Handling SIGUSR2 signal

HI, I need to handle SIGUSR2 signal in my application to change the state of the application dynamically. I have implemented the signal handler. However the application is able to catch only one SIGUSR2 signal. The second SIGUSR2 signal causes the application to crash. This is happning only with... (3 Replies)
Discussion started by: diganta
3 Replies

2. UNIX for Advanced & Expert Users

signal handling in shell script

Hi can any please tell me is it possible to catch the signal in a shell script like we do in C. if yes please give me some idea or a link. (4 Replies)
Discussion started by: Raom
4 Replies

3. 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

4. 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

5. UNIX for Advanced & Expert Users

thread context switches: detection, prevention

#1: does anyone know how to detect how many times (and/or the time length) a given thread has been context switched out of the CPU? #2: are there any tchniques that minimize/eliminate your thread getting context switched? I would be happy to know the answers to these questions for ANY... (2 Replies)
Discussion started by: fabulous2
2 Replies

6. 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

7. 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

8. Programming

problem in SIGSEGV signal handling

i wrote handler for sigsegv such that i can allocate memory for a variable to which sigsegv generated for illlegal acces of memory. my code is #include <signal.h> #include<stdio.h> #include<stdlib.h> #include<string.h> char *j; void segv_handler(int dummy) { j=(char *)malloc(10); ... (4 Replies)
Discussion started by: pavan6754
4 Replies

9. 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

10. Programming

problem in reforking and signal handling

hi friends i have a problem in signal handling ... let me explain my problem clearly.. i have four process .. main process forks two child process and each child process again forks another new process respectively... the problem is whenever i kill the child process it is reforking and the... (2 Replies)
Discussion started by: senvenugopal
2 Replies
PTHREAD_SIGMASK(3)					     Linux Programmer's Manual						PTHREAD_SIGMASK(3)

NAME
pthread_sigmask - examine and change mask of blocked signals SYNOPSIS
#include <signal.h> int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset); Compile and link with -pthread. DESCRIPTION
The pthread_sigmask() function is just like sigprocmask(2), with the difference that its use in multithreaded programs is explicitly speci- fied by POSIX.1-2001. Other differences are noted in this page. For a description of the arguments and operation of this function, see sigprocmask(2). RETURN VALUE
On success, pthread_sigmask() returns 0; on error, it returns an error number. ERRORS
See sigprocmask(2). CONFORMING TO
POSIX.1-2001. NOTES
A new thread inherits a copy of its creator's signal mask. EXAMPLE
The program below blocks some signals in the main thread, and then creates a dedicated thread to fetch those signals via sigwait(3). The following shell session demonstrates its use: $ ./a.out & [1] 5423 $ kill -QUIT %1 Signal handling thread got signal 3 $ kill -USR1 %1 Signal handling thread got signal 10 $ kill -TERM %1 [1]+ Terminated ./a.out Program source #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <errno.h> /* Simple error handling functions */ #define handle_error_en(en, msg) do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0) static void * sig_thread(void *arg) { sigset_t *set = (sigset_t *) arg; int s, sig; for (;;) { s = sigwait(set, &sig); if (s != 0) handle_error_en(s, "sigwait"); printf("Signal handling thread got signal %d ", sig); } } int main(int argc, char *argv[]) { pthread_t thread; sigset_t set; int s; /* Block SIGINT; other threads created by main() will inherit a copy of the signal mask. */ sigemptyset(&set); sigaddset(&set, SIGQUIT); sigaddset(&set, SIGUSR1); s = pthread_sigmask(SIG_BLOCK, &set, NULL); if (s != 0) handle_error_en(s, "pthread_sigmask"); s = pthread_create(&thread, NULL, &sig_thread, (void *) &set); if (s != 0) handle_error_en(s, "pthread_create"); /* Main thread carries on to create other threads and/or do other work */ pause(); /* Dummy pause so we can test program */ } SEE ALSO
sigaction(2), sigpending(2), sigprocmask(2) pthread_create(3), pthread_kill(3), sigsetops(3), pthreads(7), signal(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-01-25 PTHREAD_SIGMASK(3)
All times are GMT -4. The time now is 08:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy