On Thu, 2005-03-31 at 18:45 +0200, Paul J Stevens wrote:
> Geo Carncross wrote:
> > Be careful doing non-atomic things during signals. Since the signal will
> > likely have to write to a fifo anyway, it may be better to simply select
> > () on that fifo in the first-place...
> 
> SELECT mtime FROM dbmail_mailboxes WHERE mailbox_idnr='%llu';
> 
> seems pretty atomic to me. No need for fifos at all.

Not during a signal handler.
http://mirbsd.bsdadvocacy.org/cman/man2/sigaction.htm

The following functions are either reentrant or not interruptible by
signals and are async-signal safe.  Therefore applications may invoke
them, without restriction, from signal-catching functions:

     Base Interfaces:

     _exit(), access(), alarm(), cfgetispeed(), cfgetospeed(), cfsetispeed(),
     cfsetospeed(), chdir(), chmod(), chown(), close(), creat(), dup(),
     dup2(), execle(), execve(), fcntl(), fork(), fpathconf(), fstat(),
     fsync(), getegid(), geteuid(), getgid(), getgroups(), getpgrp(), get-
     pid(), getppid(), getuid(), kill(), link(), lseek(), mkdir(), mkfifo(),
     open(), pathconf(), pause(), pipe(), raise(), read(), rename(), rmdir(),
     setgid(), setpgid(), setsid(), setuid(), sigaction(), sigaddset(), sig-
     delset(), sigemptyset(), sigfillset(), sigismember(), signal(), sigpend-
     ing(), sigprocmask(), sigsuspend(), sleep(), stat(), sysconf(),
     tcdrain(), tcflow(), tcflush(), tcgetattr(), tcgetpgrp(), tcsendbreak(),
     tcsetattr(), tcsetpgrp(), time(), times(), umask(), uname(), unlink(),
     utime(), wait(), waitpid(), write().

     Realtime Interfaces:

     aio_error(), clock_gettime(), sigpause(), timer_getoverrun(),
     aio_return(), fdatasync(), sigqueue(), timer_gettime(), aio_suspend(),
     sem_post(), sigset(), timer_settime().

Unless we can be certain that the db backend won't do ANY SYSTEM CALL
except these, we need to wait until the signal handler is done. I know
for one, SQLite would need to use calls not here (notably: flock() and
mmap())

Also note that "errno" can be problematic:

"Additionally, it is advised that signal handlers guard against
modification of the external symbol errno by the above functions, saving
it at entry and restoring it on return, thus:

           void
           handler(sig)
           {
                   int save_errno = errno;

                   ...
                   errno = save_errno;
           }


-- 
Internet Connection High Quality Web Hosting
http://www.internetconnection.net/

Reply via email to