lua-users home
lua-l archive

Re: Solution to catching signals without using Lua hooks

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>>>> "PD" == Patrick Donnelly <batrick.donnelly@gmail.com> writes:
 PD> lua_newthread(). I haven't run into any issues yet, but I wonder if
 PD> this solution has any problems or side effects I don't see?
yep, the first and most important is that malloc() must not be
called in signal handler nor any others libc
functions. furthermore, not all syscalls may be used,
too. please read following:
 Async-signal-safe functions
 A signal handling routine established by sigaction(2) or signal(2) must
 be very careful, since processing elsewhere may be interrupted at some
 arbitrary point in the execution of the program. POSIX has the concept
 of "safe function". If a signal interrupts the execution of an unsafe
 function, and handler calls an unsafe function, then the behavior of
 the program is undefined. POSIX.1-2003 requires an implementation to
 guarantee that the following functions can be safely called inside a
 signal handler:
 _Exit(), _exit(), abort(), accept(), access(), aio_error(), aio-
 _return(), aio_suspend(), alarm(), bind(), cfgetispeed(), cfget-
 ospeed(), cfsetispeed(), cfsetospeed(), chdir(), chmod(), chown(),
 clock_gettime(), close(), connect(), creat(), dup(), dup2(), execle(),
 execve(), fchmod(), fchown(), fcntl(), fdatasync(), fork(), fpath-
 conf(), fstat(), fsync(), ftruncate(), getegid(), geteuid(), getgid(),
 getgroups(), getpeername(), getpgrp(), getpid(), getppid(), get-
 sockname(), getsockopt(), getuid(), kill(), link(), listen(), lseek(),
 lstat(), mkdir(), mkfifo(), open(), pathconf(), pause(), pipe(),
 poll(), posix_trace_event(), pselect(), raise(), read(), readlink(),
 recv(), recvfrom(), recvmsg(), rename(), rmdir(), select(), sem_post(),
 send(), sendmsg(), sendto(), setgid(), setpgid(), setsid(), setsock-
 opt(), setuid(), shutdown(), sigaction(), sigaddset(), sigdelset(),
 sigemptyset(), sigfillset(), sigismember(), signal(), sigpause(), sig-
 pending(), sigprocmask(), sigqueue(), sigset(), sigsuspend(), sleep(),
 socket(), socketpair(), stat(), symlink(), sysconf(), tcdrain(),
 tcflow(), tcflush(), tcgetattr(), tcgetpgrp(), tcsendbreak(), tcset-
 attr(), tcsetpgrp(), time(), timer_getoverrun(), timer_gettime(),
 timer_settime(), times(), umask(), uname(), unlink(), utime(), wait(),
 waitpid(), write().
-- 
Yours sincerely, Eugeny.
Doctor Web, Ltd. http://www.drweb.com
+79119997425

AltStyle によって変換されたページ (->オリジナル) /