11-19-2005
could you please let us know the semantics of signal which you are using?
is it through the old semantics
registering signal handlers using signal();
or through the new semantcis
registering the signals through masking the sigset and then using the sigaction handler
though new semantics of signals are constructed over the prevailing old semantics
there had always been a viable threat when using older semantics of signals
i) when the handlers of SIGUSR2 are used and then again encountered with SIGUSR2 the handlers need to re-registered that is the function address needs to re-presented to the kernel
ii) there had been no blocking and concept of delivering at a later pt of time with the concept of older semantics
iii) case is left for an unpredictable behaviour when handler for SIGUSR2 is being executed and while execution of the handler again a SIGUSR2 is delivered.
jim: As you had mentioned problem could be with the handler of SIGUSR2 but thats only a possibility. If it had been so, why it refused to crash in the first-handle?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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
2. UNIX for Advanced & Expert Users
hi
I have created a application which uses SIGUSR2. It send this signal to server and waits for signal SIGUSR2 from server after server performing some operation server sends SIGUSR2 back to the application. The application then quits.
This works fine which ran from terminal , but when I... (3 Replies)
Discussion started by: khan_069
3 Replies
3. Programming
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
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. Programming
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
6. Programming
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
7. Programming
Hi guys,
this is my first posting, so at first hi to everyone! ;)
I have a problem with ucontext_t in connection with signal handling. I want to simulate a preemptive scheduler. I am using the iTimer with ITIMER_PROF, to schedule the interrupts. You find the code below:
#include <stdio.h>... (18 Replies)
Discussion started by: XComp
18 Replies
8. Programming
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
9. UNIX and Linux Applications
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
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
LEARN ABOUT PHP
pcntl_signal
PCNTL_SIGNAL(3) 1 PCNTL_SIGNAL(3)
pcntl_signal - Installs a signal handler
SYNOPSIS
bool pcntl_signal (int $signo, callable|int $handler, [bool $restart_syscalls = true])
DESCRIPTION
The pcntl_signal(3) function installs a new signal handler or replaces the current signal handler for the signal indicated by $signo.
PARAMETERS
o $signo
- The signal number.
o $handler
- The signal handler. This may be either a callable, which will be invoked to handle the signal, or either of the two global con-
stants SIG_IGN or SIG_DFL, which will ignore the signal or restore the default signal handler respectively. If a callable is
given, it must implement the following signature:
void handler (int $signo)
o $signo
- The signal being handled.
Note
Note that when you set a handler to an object method, that object's reference count is increased which makes it persist
until you either change the handler to something else, or your script ends.
o $restart_syscalls
- Specifies whether system call restarting should be used when this signal arrives.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 4.3.0 | |
| | |
| | As of PHP 4.3.0 PCNTL uses ticks as the signal |
| | handle callback mechanism, which is much faster |
| | than the previous mechanism. This change follows |
| | the same semantics as using "user ticks". You |
| | must use the declare() statement to specify the |
| | locations in your program where callbacks are |
| | allowed to occur for the signal handler to func- |
| | tion properly (as used in the example below). |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
pcntl_signal(3) example
<?php
// tick use required as of PHP 4.3.0
declare(ticks = 1);
// signal handler function
function sig_handler($signo)
{
switch ($signo) {
case SIGTERM:
// handle shutdown tasks
exit;
break;
case SIGHUP:
// handle restart tasks
break;
case SIGUSR1:
echo "Caught SIGUSR1...
";
break;
default:
// handle all other signals
}
}
echo "Installing signal handler...
";
// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGUSR1, "sig_handler");
// or use an object, available as of PHP 4.3.0
// pcntl_signal(SIGUSR1, array($obj, "do_something"));
echo"Generating signal SIGUSR1 to self...
";
// send SIGUSR1 to current process id
// posix_* functions require the posix extension
posix_kill(posix_getpid(), SIGUSR1);
echo "Done
";
?>
NOTES
pcntl_signal(3) doesn't stack the signal handlers, but replaces them.
SEE ALSO
pcntl_fork(3), pcntl_waitpid(3).
PHP Documentation Group PCNTL_SIGNAL(3)