-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to stop it friendly #260
Comments
Good question. A friend way I knew is to catch the system signal to exit the process. The code listed below:
Welcome to post your PR after you have tested it. Thanks. |
This is not the right way, in *unix system only some c api can called in signal handler
发自我的iPhone
在 2020年7月11日,上午5:18,kytooooo <notifications@github.com> 写道:
Good question.
A friend way I knew is to catch the system signal to exit the process.
The code below:
`
void releaseYourMemory()
{
//TODO release your memory
}
void func1()
{
releaseYourMemory();
exit(0);
}
void func2()
{
releaseYourMemory();
exit(0);
}
void func3()
{
releaseYourMemory();
exit(0);
}
void main()
{
signal (SIGINT, func1);
signal(SIGKILL, func0);
signal(SIGSEGV, func3);
signal(SIGTERM, func2);
while (1)
{
//your loop
}
}
`
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#260 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADDQZK2GYLE3BI4DD7SHYLTR26AQXANCNFSM4OVN7NHA>.
|
The routine handler must be very careful, since processing elsewhere was interrupted at some arbitrary point. POSIX has the concept of "safe function". If a signal interrupts an unsafe function, and handler calls an unsafe function, then the behavior is undefined. Safe functions are listed explicitly in the various standards. The POSIX.1-2003 list is _Exit() _exit() abort() accept() access() aio_error() aio_return() aio_suspend() alarm() bind() cfgetispeed() cfgetospeed() cfsetispeed() cfsetospeed() chdir() chmod() chown() clock_gettime() close() connect() creat() dup() dup2() execle() execve() fchmod() fchown() fcntl() fdatasync() fork() fpathconf() fstat() fsync() ftruncate() getegid() geteuid() getgid() getgroups() getpeername() getpgrp() getpid() getppid() getsockname() 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() setsockopt() setuid() shutdown() sigaction() sigaddset() sigdelset() sigemptyset() sigfillset() sigismember() signal() sigpause() sigpending() sigprocmask() sigqueue() sigset() sigsuspend() sleep() socket() socketpair() stat() symlink() sysconf() tcdrain() tcflow() tcflush() tcgetattr() tcgetpgrp() tcsendbreak() tcsetattr() tcsetpgrp() time() timer_getoverrun() timer_gettime() timer_settime() times() umask() uname() unlink() utime() wait() waitpid() write(). |
I try to stop NFServer friendly but it not work, The callback function "ApplictionCtrlHandler" will be HOOK some exit event for window but it do nothing work. so it is any plant to make a command plugin to control the NFServer.
Thank you very much!
The text was updated successfully, but these errors were encountered: