论坛风格切换切换到宽版
  • 688阅读
  • 2回复

[问题求助][sigsuspend ]Protecting a critical region from a signal [复制链接]

上一主题 下一主题
离线liuxiao30.
 
发帖
2037
C币
-140620
威望
363
贡献值
1
银元
-1
铜钱
4544
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
代码看的不是很懂,
$ ./a.out
   program. start:(        游戏          )
   in critical regi..on: SIGINT            杀毒

   ^?            .   .                type the interrupt character           建材
   in sig_int: SIGINT SIGUSR1//为什么这里是捕.获的是.SIGUSR1???谁能大致讲一下这个代码[成人用品]
   after return from si.gsuspen.d: SIGINT域名
   prog.ram exit:.

#inclu.de "apue.h".

static void .sig_int(int);虚拟主机

int
main(void)
{
 &.nbsp;  sigset_t    newmask, oldmask, waitma.sk;

    pr_mask("program start..: ");教育

 &nbs.p;  if (signal(SIGINT, sig_int) == SIG_.ERR)[成人用品]
     &nbs.p;&nbs.p; err_sys("sign.al(SIGINT) error");电影
    s.igem.ptyset(&waitmask);.
    sigaddset.(&waitmask, SIGUS.R1);             电子
   &.nbsp;sigemptyset(&newma.sk);            杀毒
    .sigaddset(&n.ewmask, SIGINT);<性病>

&nb.sp;  &n.bsp;/*             汽车
 &n.bsp;  &nb.sp;* Block SIGINT and save current signal mask.电脑
&nbs.p;&n.bsp;   */--------------彩票
    if (sigprocmask(SIG_BLOCK, &newmask,.. &oldmask) < 0).
   &nb.sp;   &nbsp.;err_sys("SIG_BLOCK error");健康

   .&nbsp.;/*             汽车
 .    * Cr.itical region of code.--- 印刷
 &.nbsp;  &.nbsp;*/    外汇
&.nbsp; .  pr_mask("in critical region: ");--- 印刷

 &n.bsp; &nb.sp;/*    美容
     * Pause, allowing all signals except. SIGUS.R1.电影
 ..    */             汽车
  &nbs.p; if (sigsuspend(.&waitmask) != -1).
     .  &nb.sp;err_sys(."sigsuspend error");.

    pr_mask("after return from s.igsuspend: ".);.

 .   ./*<性病>
 &nbsp.;   * Reset signal mask which un.blocks SIGINT.(        游戏          )
    &.nb.sp;*/[成人用品]
    if (sigprocmask(SIG_SETMASK, &oldmask,. NULL) < .0)外贸
&n.bsp;     &nbsp.; err_sys("SIG_SETMA.SK error");.

&nb.sp; &n.bsp; /*.
   &.nbsp; * And conti.nue processing ...<性病>
 &nbs..p;   */.
&n.bsp;   pr_mask.("program exit: ");              乙肝

  .  exit(.0);    外汇
}

static void
sig_int(int .signo)             汽车
{
    pr_mask("\nin sig_int.: ");.[成人用品]
}



[ 本帖最后由 jieao.111 于 2009-.4-20 15:36 编辑 ]学习

评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线georgezhang.
发帖
2009
C币
-60878
威望
370
贡献值
1
银元
0
铜钱
4467
人人网人气币
0
只看该作者 沙发  发表于: 2010-04-13
Re:[sigsuspend
没研究过源码,帮你顶一下

发帖
2078
C币
-139174
威望
403
贡献值
1
银元
-3
铜钱
4616
人人网人气币
0
只看该作者 板凳  发表于: 2010-04-13
Re:[sigsuspend
去kernel版问问吧。
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个