简体   繁体   English

bash:如何知道被困时生成信号的来源?

[英]bash: How to know the source of generated signals when trapped?

I wish to know, when a signal is caught at my signal handler, who really generated the signal. 我想知道,当信号处理器发出信号时,谁真正产生了信号。 Is it user generated, or system generated, or by the OOM (Out-Of-Memory Management). 是用户生成的,还是系统生成的,还是由OOM(Out-Of-Memory Management)生成的。 The problem is, i am running database alterations using percona toolkit, and it is getting stopped everytime using SIGHUP after some 2-3 hours. 问题是,我正在使用percona工具包运行数据库更改,并且在大约2-3小时后每次使用SIGHUP都会停止。

I installed a signal handler, to catch it, but wish to knwo, where it came from. 我安装了一个信号处理程序,以便捕获它,但希望知道它来自哪里。 An example program is below: 示例程序如下:

trapCount=0

trapFunc()
{
 trapCount=`expr $trapCount + 1`
 echo "Sighup received...$trapCount" # But how to know who generated it
}

trap 'trapFunc' HUP

while [ 1 ]
do
 echo "First Line"
 sleep 1
 echo "Second Line"
 sleep 1
 echo "Third Line"
 sleep 1
 echo "Fourth Line"
 sleep 1
 echo "Sixth Line"
 sleep 1
 echo "Seventh Line"
 sleep 1
 echo "Eighth Line"
done

You can't; 你不能; signals are delivered by the operating system, on behalf of an anonymous signaler. 信号由操作系统代表匿名信号传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM