1833828 Members
2130 Online
110063 Solutions
New Discussion

Re: sigpause SIGUSR2

 
SOLVED
Go to solution
Srinivasan S_1
Advisor

sigpause SIGUSR2

Hi,
I was just trying with sigpause program,

My system details are as follows:

Machine: HP-UX xxxxxxx B.11.11 U 9000/800 178484665 unlimited-user license

Compiler :
/usr/bin/cc:
$Revision: 92453-07 linker linker crt0.o B.11.16.01 030316 $
LINT B.11.11.10 CXREF B.11.11.10
HP92453-01 B.11.11.10 HP C Compiler
$ PATCH/11.00:PHCO_27774 Oct 3 2002 09:45:59 $


------------------------
#include
#include

void Signal(int sig) {
printf("-------------------------------------------->Signal Caught\n");
}
int main() {
int a_nRc;
int k,l;
printf("Process ID is %d\n",getpid());
int a_stMask;
struct sigaction a_stSigAction;
memset( &a_stSigAction, NULL, sizeof(struct sigaction));
a_stSigAction.sa_handler = Signal;
a_nRc = sigaction(SIGUSR2,&a_stSigAction,NULL);
a_nRc = sigaction(SIGUSR1,&a_stSigAction,NULL);
a_nRc = sigaction(SIGALRM,&a_stSigAction,NULL);
l=0;

if ( 0 != a_nRc ){
printf("Error\n");
}

a_stMask = sigblock (sigmask (SIGALRM) | sigmask (SIGTERM));
sigpause(&a_stMask);
printf("After Signal Suspend\n");
printf("After UnBlocking.........\n");

}
----------
Problem : If I send SIGUSR2 to above program from another terminal then signal is not handled though signal handler is defined.
But if I send SIGUSR1 it is handled.

ie., kill -USR1 ( Signal is trapped)
but kill -USR2 ( Signal not trapped)

Question:
a) Is the program correct ?
b) Though I am aware that sigblock is deprecated and we should use sigprocmask,I was just trying.

But I have a question.

Is sigpause(0) is same as sigpause(mask) where mask is union of all signal.


Please help.

Thanks in Advance

With Regards,
Srinivasan S
2 REPLIES 2
Stephen Keane
Honored Contributor
Solution

Re: sigpause SIGUSR2

CHANGE
int a_stMask;
TO
long a_stMask;
AND
sigpause(&a_stMask);
TO
sigpause(a_stMask);

Unless your man sigpause(3C) is different to mine, the function prototype is:

long sigpause(long mask);

NOT

int sigpause(int * mask);




Srinivasan S_1
Advisor

Re: sigpause SIGUSR2

Thanks.
-:) I realize the silly overlook and mistake.