Sponsored Content
Full Discussion: signal() and sigsetjmp()
Top Forums UNIX for Dummies Questions & Answers signal() and sigsetjmp() Post 302323111 by bashdrew on Friday 5th of June 2009 11:47:21 AM
Old 06-05-2009
signal() and sigsetjmp()

Hi,


I am basically new to signals in UNIX. My question is, should the signal() command be called only once in the program? What will happen if it's called multiple times? I am trying to write an alarm program where the signal handler function changes in runtime. It just doesn't work if I just call signal() once at the top of the program. And I also have 2 sigsetjmp() calls in the program. I really appreciate any help. Thanks.


Regards,
bashdrew

Last edited by bashdrew; 06-05-2009 at 12:58 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Signal Processing

Hello, Can any body give example of using Unix Signals. What I want to do is I am running a sql query in a shell script I want, if sql query exceed the defined no. of seconds limit, then I would like to kill the process. I know this can be done thru Unix Signal Handling but I do not know... (8 Replies)
Discussion started by: sanjay92
8 Replies

2. UNIX for Advanced & Expert Users

Kill Signal

Hello, I'm doing a project of OS simulation (Process Scheduling, to be very specific). Can anyone, please, explain what exactly happens in the background when we see "Sending all processes the KILL signal...........". How is it sent to each process? Is it that something like a boolean is stored... (3 Replies)
Discussion started by: ameya
3 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 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

5. Shell Programming and Scripting

signal script?

I have a script which invoke a java program, because the program requires file as input, hence the script would sleep a X seconds then check for file existence, if the file exists then program is invoker else, keep waiting until the time is up. My problem is that if there is a way to find out if my... (1 Reply)
Discussion started by: mpang_
1 Replies

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

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

8. UNIX for Advanced & Expert Users

need more user signal

Hi In my program I have already used both SIGUSR1 SIGUSR2 user signals. I need another one. How can I do that? Thank you Naama (1 Reply)
Discussion started by: naamabm
1 Replies

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

10. 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
SETJMP(3)						   BSD Library Functions Manual 						 SETJMP(3)

NAME
sigsetjmp, siglongjmp, setjmp, longjmp, _setjmp, _longjmp, longjmperror -- non-local jumps LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <setjmp.h> int sigsetjmp(sigjmp_buf env, int savemask); void siglongjmp(sigjmp_buf env, int val); int setjmp(jmp_buf env); void longjmp(jmp_buf env, int val); int _setjmp(jmp_buf env); void _longjmp(jmp_buf env, int val); void longjmperror(void); DESCRIPTION
The sigsetjmp(), setjmp(), and _setjmp() functions save their calling environment in env. Each of these functions returns 0. The corresponding longjmp() functions restore the environment saved by the most recent invocation of the respective setjmp() function. They then return so that program execution continues as if the corresponding invocation of the setjmp() call had just returned the value specified by val, instead of 0. Pairs of calls may be intermixed, i.e., both sigsetjmp() and siglongjmp() as well as setjmp() and longjmp() combinations may be used in the same program. However, individual calls may not, e.g., the env argument to setjmp() may not be passed to siglongjmp(). The longjmp() routines may not be called after the routine which called the setjmp() routines returns. All accessible objects have values as of the time longjmp() routine was called, except that the values of objects of automatic storage invo- cation duration that do not have the volatile type and have been changed between the setjmp() invocation and longjmp() call are indetermi- nate. The setjmp()/longjmp() function pairs save and restore the signal mask while _setjmp()/_longjmp() function pairs save and restore only the register set and the stack. (See sigprocmask(2).) The sigsetjmp()/siglongjmp() function pairs save and restore the signal mask if the argument savemask is non-zero. Otherwise, only the reg- ister set and the stack are saved. In other words, setjmp()/longjmp() are functionally equivalent to sigsetjmp()/siglongjmp() when sigsetjmp() is called with a non-zero savemask argument. Conversely, _setjmp()/_longjmp() are functionally equivalent to sigsetjmp()/siglongjmp() when sigsetjmp() is called with a zero-value savemask. The sigsetjmp()/siglongjmp() interfaces are preferred for maximum portability. ERRORS
If the contents of the env are corrupted or correspond to an environment that has already returned, the longjmp() routine calls the routine longjmperror(3). If longjmperror() returns, the program is aborted (see abort(3)). The default version of longjmperror() prints the message ``longjmp botch'' to standard error and returns. User programs wishing to exit more gracefully should write their own versions of longjmperror(). SEE ALSO
sigaction(2), sigaltstack(2), sigprocmask(2), pthread_sigmask(3), signal(3) STANDARDS
The setjmp() and longjmp() functions conform to ANSI X3.159-1989 (``ANSI C89''). The sigsetjmp() and siglongjmp() functions conform to ISO/IEC 9945-1:1990 (``POSIX.1''). CAVEATS
Historically, on AT&T System V UNIX, the setjmp()/longjmp() functions have been equivalent to the BSD _setjmp()/_longjmp() functions and do not restore the signal mask. Because of this discrepancy, the sigsetjmp()/siglongjmp() interfaces should be used if portability is desired. Use of longjmp() or siglongjmp() from inside a signal handler is not as easy as it might seem. Generally speaking, all possible code paths between the setjmp() and longjmp() must be signal race safe. Furthermore, the code paths must not do resource management (such as open(2) or close(2)) without blocking the signal in question, or resources might be mismanaged. Obviously this makes longjmp() much less useful than previously thought. BSD
June 1, 2008 BSD
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy