我有以下sigaction处理函数
void signal_term_handler(int sig) { printf("EXIT :TERM signal Received!\n"); int rc = flock(pid_file,LOCK_UN | LOCK_NB); if(rc) { char *piderr = "PID file unlock Failed!"; fprintf(stderr,"%s\n",piderr); printf(piderr); } abort(); }
有人告诉我,flock和printf不是异步信号安全的.而且我找不到另一个异步信号安全函数flockin这个list.@H_404_5@
when a signal interrupts an unsafe function and the signal-catching
function calls an unsafe function,the behavior is undefined@H_404_5@
有没有办法使flock异步信号安全?或者,当我收到TERM信号时,是否有另一种解决方案来执行flock?@H_404_5@