I have a java application that got SIG TERM. I want to know the pid of the process that sent this signal.
Is that possible?
I have a java application that got SIG TERM . I want to know
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two Linux-specific methods are
SA_SIGINFOandsignalfd(), which allows programs to receive very detailed information about signals sent, including the sender’s PID.Call
sigaction()and pass to it astruct sigactionwhich has the desired signal handler insa_sigactionand theSA_SIGINFOflag insa_flagsset. With this flag, your signal handler will receive three arguments, one of which is asiginfo_tstructure containing the sender’s PID and UID.Call
signalfd()and readsignalfd_siginfostructures from it (usually in some kind of a select/poll loop). The contents will be similar tosiginfo_t.Which one to use depends on how your application is written; they probably won’t work well outside plain C, and I wouldn’t have any hope of getting them work in Java. They are also unportable outside Linux. They also likely are the Very Wrong Way of doing what you are trying to achieve.