⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 catchsig.c

📁 在Unix平台下完成的电力系统广发使用的IEC103规约的程序
💻 C
字号:
/*   
 ***********************************************************************
 *                      NARI   Software
 *            Network Automatic Realtime Interactive software
 *      Copyright (c) 1993, Nanjing Automation Research Institute
 *                   All Rights Reserved
 *
 * Name        : @(#)catchsig.c	1.1  8/4/93
 * 
 * Programmer  : ZHAO TIANHONG
 *
 * Description : 
 *
 * include	: 
 *
 * Compile     : 
 *
 * History     :
 *
 ***********************************************************************/




/*******************************************************************************
* This is the skeleton for the signal handling shutdown function - to set up   *
* signal handling for SIGUSR1, just call:                                      *
*                                                                              *
*     init_sighandler( &appl_data );                                           *
*                                                                              *
*  where "appl_data" is a buffer/struct containing data that sighandler()      *
*  can use when it is cleaning up prior to exiting - it is OK for              *
*  you to call init_sighandler() with a NULL pointer - if you do, then         *
*  "static_pappl_data" will be NULL.                                           *
*                                                                              *
*  Add whatever code you want to the sighandler() function to perform          *
*  your application-specific shudown - if you were talking over the            *
*  network (your process called msg_init()), then do NOT forget to call the    *
* "msg_delete()" function to deallocate your network resources.                *
*******************************************************************************/

#include <stdio.h>
#include <signal.h>
#include <sys/types.h>

void	sighandler();

/* 'static_pappl_data' is a pointer to some data you want to have available
   to sighandler() when it catches SIGUSR1 */

/******************************************************************************/

/* to catch the interrupt signal for shutdown */
void init_sighandler( )
{

/* set up sighandler() as the signal handler for SIGUSR1 */
   (void)signal( SIGUSR1, sighandler );
}

/******************************************************************************/

/* signal handler called when application catches a SIGUSR1 */
void sighandler( sig, code, scp, addr )
int		sig,
		code;
struct sigcontext
		*scp;
char		*addr;
{
/* this is the skeleton for the signal handler - you may do ANY kind of
   cleanup/shutdown processing you desire, just make certain that you
   exit( 0 ) when you are done... */
   msg_delete(); 
   exit( 0 );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -