Sponsored Content
Top Forums Programming Serial port signal(IRQ) handler (using C) Post 302931914 by achenle on Friday 16th of January 2015 10:49:40 AM
Old 01-16-2015
You can't safely use malloc() or pthread_mutex_lock() in a signal handler. You can only use async-signal safe calls in a signal handler. A list of Linux async-signal safe calls can be found here:

signal(7) - Linux manual page
This User Gave Thanks to achenle For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script signal handler

AIX 4.3.3 I am trying to write a signal handler into a ksh shell script. I would like to capture the SIGTERM, SIGINT, and the SIGTSTP signals, print out a message to the terminal, and continue executing the script. I have found a way to block the signals: #! /bin/ksh SIGTERM=15 SIGINT=2... (2 Replies)
Discussion started by: jalburger
2 Replies

2. Solaris

serial port signal

hi i am using solaris 9 on sparc . i was wondering if there was a command to control my serial interface , as to send a signal periodically every interval of time to the input of a 555 timer . thanks for your help .... (0 Replies)
Discussion started by: ppass
0 Replies

3. Programming

signal handler for SIGCHLD

Hi, I have an c++ application which uses the function fork and execvp(). The parent does not wait until the child ends. The parents just creates children and let them do their stuff. You can see the parent program as a batch-manager. I have added a SIGCHLD handler to the program: void... (3 Replies)
Discussion started by: jens
3 Replies

4. Programming

signal handler problems

Hey guys, I am trying to write a little shell, and was writing a signal handler to handle SIGINT (I am using 'stty intr ^C' and using ctrl-C to give SIGINT). I wrote this signal handler: void handle_sigint() { write(2,"handling sigint\n",16); write(1,"\nshell% ",8); } ... (4 Replies)
Discussion started by: blowtorch
4 Replies

5. Programming

Runaway SIGALRM signal handler

I have written a program to demonstrate a problem I have encountered when using BSD style asynchronous input using the O_ASYNC flag in conjunction with a real time interval timer sending regular SIGALRM signals to the program. The SIGIO handler obeys all safe practices, using only an atomic update... (8 Replies)
Discussion started by: stewartw
8 Replies

6. Shell Programming and Scripting

Perl - Problems with Signal Handler

I have a problem with signal handlers not working. I have a long 1000 line code and somehow this code for signal handling is not working: $SIG{INT} = \&interrupt; sub interrupt { print STDERR "Caught a control c!\n"; exit; # or just about anything else you'd want to do } Any... (2 Replies)
Discussion started by: som.nitk
2 Replies

7. UNIX for Dummies Questions & Answers

Doubt with irq handler.......

Hello, I have develop a driver for my hardware and now, I need to handle a IRQ but I does not work. As I can understand, to handle a irq, it is necessary to make a request_irq(). If the return value is zero, ok, no problem to handle irq. Here is a easy example of my driver: #include... (8 Replies)
Discussion started by: webquinty
8 Replies

8. Programming

Signal Handler Hangs

Hi, I have a problem with signal handler algorithm in linux. My code is hanging ( It is continuously looping inside the signal handler) . I am pasting my code here... Please provide me some help regarding this. I googled many places and wrote this code.. but doesnt seem to be working without... (6 Replies)
Discussion started by: sree_ec
6 Replies

9. Shell Programming and Scripting

Perl Signal Handler

I was working on some Perl code that does signal handling and I came across this one liner and wasn't sure what it was doing. local $SIG{__DIE__} = sub {$! = 2; die $_;}; I think the first part of the anonymous subroutine is setting $! to 2, but I am not sure what the second part is doing. ... (1 Reply)
Discussion started by: SFNYC
1 Replies

10. Programming

problem in doing coding of signal handler

i m unble to execute code of signal handler using a) Wait b) Waitpid (1 Reply)
Discussion started by: madhura
1 Replies
bsd_signal(2)							System Calls Manual						     bsd_signal(2)

NAME
bsd_signal - Simplified signal facilities LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <signal.h> void (*bsd_signal( int sig, void (*function)(int)))(int); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: bsd_signal(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Defines the signal. Specifies the address of a signal handler. DESCRIPTION
The bsd_signal() function provides a partially compatible interface for programs written to historical system interfaces. The handler function should be declared: void handler(int sig); where sig is the signal number. The behaviour is undefined if function is a function that takes more than one argument, or an argument of a different type. 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 will be clear when the libsys5 version of bsd_signal() is used. The state of these flags is not specified for signal(). RETURN VALUES
Upon successful completion, bsd_signal() returns the previous action for sig. Otherwise, SIG_ERR is returned and errno is set to indicate the error. ERRORS
Refer to sigaction(2). RELATED INFORMATION
Functions: sigaction(2), sigaddset(3), sigemptyset(3), signal(2) Standards: standards(5) delim off bsd_signal(2)
All times are GMT -4. The time now is 12:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy