Second signal call in sighandler - what for?

后端 未结 3 451
温柔的废话
温柔的废话 2021-01-22 02:47

Recently I found some code which uses signal:

  286 static void sighandler( int signum )
  287 {   
  288     alarmed = 1;
  289     signal( signum,         


        
3条回答
  •  鱼传尺愫
    2021-01-22 03:20

    (1) Calling signal two or more times is not unusual. It's just setting up two handlers for 2 different signals.

    (2) Older unix systems used to reset a signals disposition to default after a handler was invoked. This code is reestablishing the handler.

    The GNU man (2) signal page has a couple of paragraphs devoted to this in the "portability" section. Actually one of several reasons to use sigaction.

提交回复
热议问题