Operating System - HP-UX
1754366 Members
4667 Online
108813 Solutions
New Discussion юеВ

SIGCONT signal generated automatically

 
SOLVED
Go to solution
JoseLuis2
Occasional Contributor

SIGCONT signal generated automatically

Hi,

In this program, why is SIGCONT signal generated when only SIGUSR1 signal is sent to the process?

#include <stdio.h>
#include <signal.h>


int fib(int n)
{
  if (n == 0 || n == 1)
    return n;
  else
    return (fib(n-1) + fib(n-2));
}



void SignalHandler(int sig)
{

          printf("SIGNAL: %d\n", sig);
}


int main()
{
        int i;

        signal(SIGUSR1, SignalHandler);
        signal(SIGCONT, SignalHandler);
        signal(SIGTERM, SignalHandler);



        for(i=0; i< 100; ++i)
        {
                fib(35);
        }

}

------------------------------------------------
[fraapp31_cotafac]/tmp# a.out
SIGNAL: 26
SIGNAL: 16

[fraapp31_cotafac]/tmp# uname -a
HP-UX fraapp31 B.11.23 U ia64 1849578169 unlimited-user license

 

Thanks in advance.

Regards, Jose Luis.

 

5 REPLIES 5
laurentmenase
HPE Pro

Re: SIGCONT signal generated automatically

Hello Jose Luis,

1) printf() is not a async sinal safe function so must not be used in  a signal handler

2) with the following program you should see the signal for SIGCONT immediately

3) do you ^Z before sending a kill -USR1 to the process? ( I think I missed the initial question in my previous points), if yes, to restart a SIGCONT signal is received by the process, I don't reproduce, so how do you generate the signal

 

 

 

 

#include <stdio.h>
#include <signal.h>


int fib(int n)
{
  if (n == 0 || n == 1)
    return n;
  else
    return (fib(n-1) + fib(n-2));
}


void SignalHandlerCONT(int sig)
{

          write(1,"SIGNAL: CONT \n", strlen("SIGNAL: CONT \n"));
}
void SignalHandler(int sig)
{

          write(1,"SIGNAL: TERM \n", strlen("SIGNAL: CONT \n"));
}
void SignalHandlerUSR(int sig)
{
          write(1,"SIGNAL: USR1 \n", strlen("SIGNAL: CONT \n"));
}


int main()
{
        int i;
        signal(SIGUSR1, SignalHandlerUSR);
        signal(SIGCONT, SignalHandlerCONT);
        signal(SIGTERM, SignalHandler);

        for(i=0; i< 100; ++i)
        {
                fib(35);
        }

}

 

 

 

 

 

I am an HPE Employee (HPE Community)

 


[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
JoseLuis2
Occasional Contributor

Re: SIGCONT signal generated automatically

Hi ,

First, the program is compiled and launched:

[fraapp31_cotafac]/tmp# cc -V
cc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]
[fraapp31_cotafac]/tmp# uname -a
HP-UX fraapp31 B.11.23 U ia64 1849578169 unlimited-user license
[fraapp31_cotafac]/tmp#
[fraapp31_cotafac]/tmp# cc laurentmenase_signal.c -o laurentmenase_signal
[fraapp31_cotafac]/tmp#
[fraapp31_cotafac]/tmp# laurentmenase_signal
SIGNAL: 26
SIGNAL: 16

 

In other terminal, SIGUSR1 signal is sent to the program:

[fraapp31_cotafac]/fac/desa/cotafac/madrid/trunk/fuentes/Procesos/src# ps -ef| grep  laurentmenase_signal
cotafac    688   482 96 20:40:10 pts/0       00:05 laurentmenase_signal
cotafac    691   563  0 20:40:15 pts/1       00:00 grep laurentmenase_signal
[fraapp31_cotafac]/fac/desa/cotafac/madrid/trunk/fuentes/Procesos/src# kill -SIGUSR1 688
[fraapp31_cotafac]/fac/desa/cotafac/madrid/trunk/fuentes/Procesos/src#

 

Thanks for your help!!

Regards, Jose Luis

laurentmenase
HPE Pro

Re: SIGCONT signal generated automatically

Hello Jose Luis

Even on 11.23 I do not reproduce and get only SIGUSR1.  you may try to tusc the kill and the a.out  ( tusc -f -o /var/tmp/xy.t ./xy
and
tusc -f -o /var/tmp/kill.t kill  -USR1 <pid>

Best regards,

Laurent 


[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
JoseLuis2
Occasional Contributor
Solution

Re: SIGCONT signal generated automatically

Hi,

The problem was that I was using ksh built in kill instead of kill command (/usr/bin/ksh). This text is an extract for "man ksh":

"Signals are given either by number or name (as given in signal(5), stripped of the prefix SIG). The signal names are listed by kill -l. No default exists; merely typing kill does not affect the current job. If the signal being sent is TERM (terminate) or HUP (hangup), the job or process is sent a CONT (continue) signal when stopped. The process argument can be either a process ID or job. If the first argument to kill is a negative integer, it is interpreted as a sig argument and not as a process group. See also kill(1)."

Thanks for your help!

Regards, Jose Luis.

 

Sunitha_Mod
Moderator

Re: SIGCONT signal generated automatically

Hello Jose Luis,

That's excellent!

We are extremely glad to know you were able to find the solution, and we appreciate you for keeping us posted. 

Thanks,
Sunitha G
I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo