Sponsored Content
Top Forums UNIX for Advanced & Expert Users Not able to Display the Catched Signal Post 302688431 by shyam.sunder91 on Sunday 19th of August 2012 07:32:52 AM
Old 08-19-2012
Power Not able to Display the Catched Signal

my code here is intended to display the received signal that's it but its not working when i try to send the signal
kill -SIGUSR1 pid
or
kill -10 pid
or any other signals according to my program

Code:
#include"headers.h"
static void sig_usr(int);
main()
{
        if(signal(SIGUSR1,sig_usr)==SIG_ERR)
                printf("cant catch signal sigusr1");
        if(signal(SIGUSR2,sig_usr)==SIG_ERR)
                printf("cant catch signal sigusr2");
        while(1);
        pause();
}
static void sig_usr(int signo)
{
if(signo==SIGUSR1)
        printf("Rx sigusr1");
else if(signo==SIGUSR2)
        printf("Rx sigusr2");
else printf("recieved signal is %d",signo);
return;
}

so i debugged it
debug results:

Code:
Breakpoint 1, main () at catch_signal.c:5
5       if(signal(SIGUSR1,sig_usr)==SIG_ERR)
(gdb) n
7       if(signal(SIGUSR2,sig_usr)==SIG_ERR)
(gdb) n
9       while(1);
(gdb) n

Program received signal SIGUSR1, User defined signal 1.
main () at catch_signal.c:9
9       while(1);
(gdb) n
sig_usr (signo=10) at catch_signal.c:13
13  {
(gdb) n
14  if(signo==SIGUSR1)
(gdb) n
15      printf("Rx sigusr1");
(gdb) n

Program received signal SIGTRAP, Trace/breakpoint trap.
0x08048326 in printf@plt ()
(gdb) n
Single stepping until exit from function printf@plt,
which has no line number information.
0x08048310 in ?? ()
(gdb) n
Cannot find bounds of current function

im supposed to get the result output as Rx signal usr1 but i havnt why soSmilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

thread::signal

Hi,all! Now ,I write perl for windows platform,and will use signal for asynchronous operations ,but I find it could bring some bugs if it is used incorrectly ,pls help!!! :D (1 Reply)
Discussion started by: hhh101
1 Replies

2. UNIX for Dummies Questions & Answers

Alarm signal

Hi, when I execute a script on unix AIX, I've got an error message: "Execution: 85328 Signal d'alarme". If I edit this file with "vi", I ve got the same error after a while (about 1 minute). If I try with another user I still have the problem. But if I rename this file, no problem. My... (5 Replies)
Discussion started by: cgsteph
5 Replies

3. Shell Programming and Scripting

Signal question

Who can explain the meaning of the &2 &1 or @, #, etc in the script? Is there any document which can explain the usage of these words in details? for example: ls /etc/sysconfig/network > /dev/null 2>&1 #@ bash, ksh and sh. Thanks in advance for ur advice. (1 Reply)
Discussion started by: GCTEII
1 Replies

4. Programming

Signal Problem

I am using the signal function, and passing it a function named quit procedure...I get the following warning.... passing arg2 of signal from incompatible pointer type... void quit_procedure(void); //this is the way i define my prototype... signal(SIGINT, quit_procedure); Please guide... (5 Replies)
Discussion started by: jacques83
5 Replies

5. Shell Programming and Scripting

Killed by signal 15.

Hi all I have Master script, Main script ,and 4 Child script. Master.sh #!/bin/bash /export/home/user/Main.shMain.sh #!/bin/bash /export/home/user/Child1.sh & /export/home/user/Child2.sh & /export/home/user/Child3.sh & /export/home/user/Child4.sh &I run only Master.sh script... (1 Reply)
Discussion started by: almanto
1 Replies

6. UNIX for Dummies Questions & Answers

Trying to block signal

I have this code that doesnt do what it is suppose to do. It should block signal that I send while process is running. I press control+z while this process is running and it should be blocked but it isnt. When i press control+z it gives me this.... + Stopped When I change SIGTSP into SIGINT then... (5 Replies)
Discussion started by: joker40
5 Replies

7. UNIX for Advanced & Expert Users

DISPLAY=local_host:0.0 ; export DISPLAY

Hi, from my Windows Workstation I can connect with PUTTY to an AIX 6.1 unix server. On AIX via PUTTY I run DBCA which has a grphical interface. Then : #DISPLAY=local_host:0.0 ; export DISPLAY $(hostname) $(whoami):/appli/oracle/product/10.2.0/db_1/bin#dbca _X11TransSocketINETConnect()... (12 Replies)
Discussion started by: big123456
12 Replies

8. Programming

queue a signal

A program have to receive signals and work agreed with it, but the process have to receive more than one signal when it is attending other. Those have to be queued to be attended later recived. how can i do that? thanks. (2 Replies)
Discussion started by: marmaster
2 Replies

9. Shell Programming and Scripting

Case signal

Task 1: #!/bin/ksh if then echo "Usage : $0 Signalnumber PID" exit fi case "$1" in 1) echo "Sending SIGHUP signal" kill -SIGHUP $2 ;; 2) echo "Sending SIGINT signal" kill -SIGINT $2 ;; 3) echo "Sending SIGQUIT signal" kill -SIGQUIT $2 (3 Replies)
Discussion started by: Ramesh M
3 Replies
SIGSETOPS(3)						   BSD Library Functions Manual 					      SIGSETOPS(3)

NAME
sigemptyset, sigfillset, sigaddset, sigdelset, sigismember -- manipulate signal sets LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <signal.h> int sigemptyset(sigset_t *set); int sigfillset(sigset_t *set); int sigaddset(sigset_t *set, int signo); int sigdelset(sigset_t *set, int signo); int sigismember(sigset_t *set, int signo); DESCRIPTION
These functions manipulate signal sets stored in a sigset_t. Either sigemptyset() or sigfillset() must be called for every object of type sigset_t before any other use of the object. The sigemptyset() function initializes a signal set to be empty. The sigfillset() function initializes a signal set to contain all signals. The sigaddset() function adds the specified signal signo to the signal set. The sigdelset() function deletes the specified signal signo from the signal set. The sigismember() function returns whether a specified signal signo is contained in the signal set. sigemptyset() and sigfillset() are provided as macros, but actual functions are available if their names are undefined (with #undef name). RETURN VALUES
The sigismember() function returns 1 if the signal is a member of the set, a 0 otherwise. The other functions return 0 upon success. A -1 return value indicates an error occurred and the global variable errno is set to indicate the reason. ERRORS
These functions could fail if one of the following occurs: [EINVAL] signo has an invalid value. SEE ALSO
kill(2), sigaction(2), sigsuspend(2), signal(7) STANDARDS
These functions conform to ISO/IEC 9945-1:1990 (``POSIX.1''). BSD
June 4, 1993 BSD
All times are GMT -4. The time now is 12:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy