How can a process detect the status of a signal
Hi all,
Is it possible for a process to know what signals it handle and the handler for each signal? I looked at signal API but couldn't find it helpful. If I issue a command like this: $ nohup ./my_exe& - This process has a handler setup for SIGHUP. But if it is invoked with 'nohup' like here, the process should _ignore_ its own handler and subsequently the signal. The reason is 'nohup' sets the handler for signal SIGHUP as 'SIG_IGN'. And issuing '$kill -1 pid' should just be ignored! So is it possible for a process to know the handler for a signal(like if its SIG_IGN or SIG_DFL). This way it can decide whether to catch it or not. This program is in C. Thanks, Vishal |
Try this
Code:
#include <signal.h> #kill -HUP <pid> Keep coding -- Ashok Athukuri |
Quote:
Quote:
Consider this demonstrative C code: Code:
#include <signal.h> |
Yeah, thats true if you wanna check the current status of the signal handler and then looking for action then do like
Code:
struct sigaction oldsa; I guess that leaves you both chances to do that ... -- Ashok Athukuri |
Hi "osor" and Ashok,
Thanks so much for the help and sharing the more about signals. I mistakenly skipped sigaction()'s functionality to gather info of "previous" handler. Thanks! I could solve the issue but still nohup leaves some doubts to me. How does nohup changes signal handler for other process? As nohup should be forking the application, and changing handler for its child(But how because as far as I know signal handler info is kept in uarea? And it should be accessible to kernel or to the invoked process only)! Thanks in advance, Vishal |
Quote:
Code:
#include <signal.h> Code:
nohup somecommand its arguments
Quote:
|
All times are GMT -5. The time now is 08:00 PM. |