SIGCONT occurs after a SIGTERM

Sean Sheridan Coleman X5672 coleman at cam.nist.gov
Tue Feb 12 04:06:07 AEST 1991


Please explain to me why a SIGCONT is sent to a process after
SIGTERM is sent to my process. It doesn't compute because TERM
means to terminate the the process. I catch SIGCONT because I 
do some reconnecting for serial drivers after my process is
stopped from a cntl-Z. Below is a piece of the code and a
some output from the program. 

Here I stop the program with a ^Z and restart using fg %1.
SIGCONT is sent in this situation correctly.

<deputy /home/central/coleman/real_prog/net.dir/net_log> % net l logfile
^Z Signal caught is 18

Stopped (signal)
<deputy /home/central/coleman/real_prog/net.dir/net_log> % jobs
[1]  + Stopped (signal)     net l logfile
<deputy /home/central/coleman/real_prog/net.dir/net_log> % fg %1
net l logfile
 Signal caught is 19
^C Signal caught is 2



>From another window, I used kill -TERM  to kill this process.
SIGTERM is received first but then SIGCONT is sent for no known
reason.

<deputy /home/central/coleman/real_prog/net.dir/net_log> % !ne
net l logfile
 Signal caught is 15
 Signal caught is 19
No devices are available to use for logging


Here is the signal handler:

Note: device,device_file and device_name are global

sig_handler(sig)
int sig;
{
	extern int device;
	extern FILE *device_file;
	extern char *device_name;	
	char *strip_add_dev_name();

	printf(" Signal caught is %d\n",sig);
	switch(sig)
	{
	 	case SIGINT:
		case SIGTERM:
			unlock_dev(strip_add_dev_name(ttyname(device),0));
			exit(1);
		case SIGTSTP:			
			unlock_dev(strip_add_dev_name(ttyname(device),0));
			close(device);
			kill(0,SIGSTOP);
			break;
		case SIGCONT:	
			if(device_file != NULL)
			{
				rewind(device_file);
				device = get_device(device_file);
			}
			else
			{
				if((device = chk_device(device_name)) < 0)
				{
					printf("No devices are available to use for logging\n");
					exit(1);
				}
			}

		 default:
			break;
				
	}
}


Thanks

Sean Coleman
coleman at bldrdoc.gov
NIST
Boulder, CO



More information about the Comp.unix.wizards mailing list