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

📄 subject_44032.htm

📁 vc
💻 HTM
字号:
<p>
序号:44032 发表者:丁伟锋 发表日期:2003-06-16 07:55:05
<br>主题:这样的函数原型好奇怪。
<br>内容:void ( *signal( int sig, void (__cdecl *func) ( int sig [, int subcode ] )) ) ( int sig );<BR>这样的函数原型好奇怪。<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;if (signal(SIGINT, SIG_IGN) != SIG_IGN)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signal(SIGINT, interrupt);<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (signal(SIGTERM, SIG_IGN) != SIG_IGN)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signal(SIGTERM, interrupt);<BR>#ifdef SIGHUP<BR>&nbsp;&nbsp;&nbsp;&nbsp;if (signal(SIGHUP, SIG_IGN) != SIG_IGN)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;signal(SIGHUP, interrupt);
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:丁伟锋 回复日期:2003-06-17 07:47:18
<br>内容:我查阅了标准C的标准库signals。在signal.h中是这样的声明的:<BR>void (*signal(int sig, void (*handler)(int)))(int)<BR><BR>这样的声明怎么理解?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:bird 回复日期:2003-06-17 09:02:49
<br>内容:#include &lt;signal.h&gt;<BR>void (*signal(int signum, void (*handler))(int)))(int);<BR><BR>如果该函数原型不容易理解的话,可以参考下面的分解方式来理解:<BR>typedef void (*sighandler_t)(int);<BR>sighandler_t signal(int signum, sighandler_t handler));<BR>第一个参数指定信号的值,第二个参数指定针对前面信号值的处理,可以忽略该信号(参数设为SIG_IGN);可以采用系统默认方式处理信号(参数设为SIG_DFL);也可以自己实现处理方式(参数指定一个函数地址)。<BR>如果signal()调用成功,返回最后一次为安装信号signum而调用signal()时的handler值;失败则返回SIG_ERR。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

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