Matthew Vernon writes ("Bug#858555: chiark-utils-bin: [patch] add timeout 
option to with-lock-ex"):
> Revised patch attached. My commit message:

Thanks.

We (Mark and I) had a long discussion on irc, including after you
left, about signal handling.  Our conclusion is that you need to do:

  sigprocmask(SIG_BLOCK); sigaction; setitimer; ... other setup ...;

  for (;;) {

    stuff

    sigprocmask(SIG_UNBLOCK);
    r = fcntl;
    sigprocmask(SIG_BLOCK);
    do things with r and errno

    stuff
  }

  setitmer(cancel)
  sigprocmask(SIG_SETMASK);
  /* might still get a timeout signal handler entry here! */
  sigaction(SIG_DFL); 

  exec;

And, as you suggested, all the if (alarmed) stuff then moved into the
signal handler.

Also, to make life extra annoying, I'd like this program not to mess
with the signals at all unless it has to, so all of this should be
conditional on secs.

Ian.

Reply via email to