linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: what causes SIGTERMs?
@ 2003-07-09 19:16 Jad Saklawi
  0 siblings, 0 replies; 9+ messages in thread
From: Jad Saklawi @ 2003-07-09 19:16 UTC (permalink / raw)
  To: linux-c-programming

Hello,
check out on http://www.advancedlinuxprogramming.com/alp-folder
i think it is in chapter 3 of the book, all about signals.

why not try out using http://syscalltrack.sourceforge.net and see what is 
causing the signal
                                              Greets, Jad
Quoting Matthew Studley <matthew.studley@uwe.ac.uk>:

> Hi all
> 
> thanks for the help regarding linux signals... very useful!
> 
> I have written this little test program, which I then send a SIGTERM using
> another process.
> (I've been testing this under the current stable release of Debian)
> 
> I notice that, while siginfo_t.si_signo seems to have a meaningful value,
> all other fields e.g. si_pid are ZERO !
> 
> Does anybody have any ideas about this?
> 
> cheers Matt
> 
> ============================================
> 
> 
> #include <signal.h>
> #include <stdio.h>
> 
> /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> */
> void myHandler(int i, siginfo_t *info, void *v){
>   printf("i = %d\n", i);
>   printf("signo is %d\n", info->si_signo);
>   printf("calling pid is %d\n", info->si_pid);
>   printf("calling uid is %d\n", info->si_uid);
>   printf("errno : %d\n", info->si_errno);
>   printf("code : %d\n", info->si_code);
>   fflush(stdout);
> }
> /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> */
> int main(void){
>   int i;
>   struct sigaction mySigaction;
> 
>   mySigaction.sa_sigaction = (myHandler);
>   sigemptyset (&mySigaction.sa_mask);
>   mySigaction.sa_flags = SA_SIGINFO;      //SA_RESTART | SA_SIGINFO;
>   if(sigaction(SIGTERM, &mySigaction, NULL) < 0) {
>   perror("ERROR: registering Handler Function\n");
>   exit(1);
>   }
> 
>   while(1){
>     // do nothing.
>   }
> }
> /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> */
> 
> ========
> >
> > Matthew Studley wrote:
> >
> > > I wonder whether you could help me?  I have a problem; I'm running an
> > > application I've written in C under Slackware 7.1  Occasionally it
> receives
> > > a SIGTERM.
> > >
> > > * In what circumstances do processes get sent a SIGTERM?
> >
> > If something raises it with kill(). Note that SIGTERM is the default
> > signal sent by the kill and killall commands.
> >
> > > * Am I correct that this is unlikely to be issued in response to a bug
> in my
> > > code?
> >
> > Correct. SIGTERM isn't sent synchronously (i.e. in response to the
> > actions of the process which receives it).
> >
> > > * How can I find which process is issuing the SIGTERM against my code?
> >
> > Install a signal handler using sigaction() with the SA_SIGINFO flag;
> > the sending process ID will be in the si_pid field of the siginfo_t
> > structure. Other fields of that structure may also contain useful
> > information.
> >
> > --
> > Glynn Clements <glynn.clements@virgin.net>
> >
> >
> 
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 




^ permalink raw reply	[flat|nested] 9+ messages in thread
* what causes SIGTERMs?
@ 2003-07-08 13:17 Matthew Studley
  2003-07-08 13:26 ` Francis Lau
  2003-07-08 14:27 ` Glynn Clements
  0 siblings, 2 replies; 9+ messages in thread
From: Matthew Studley @ 2003-07-08 13:17 UTC (permalink / raw)
  To: linux-c-programming

Hi All

I wonder whether you could help me?  I have a problem; I'm running an
application I've written in C under Slackware 7.1  Occasionally it receives
a SIGTERM.

* In what circumstances do processes get sent a SIGTERM?

* Am I correct that this is unlikely to be issued in response to a bug in my
code?

* How can I find which process is issuing the SIGTERM against my code?

* Are there any changes I can make to the execution environment / logging /
gcc compilation options to help me find out why this is happening?

If anybody can give me some ideas, or suggest directions to investigate, I'd
be hugely thankful!

Just as a bit of background; the platform is a robot on which I have
recently fitted some new hardware.  The SIGTERM problem started at roughly
the same time.  If I catch the SIGTERM, and do nothing apart from continue
my application... I then catch more SIGTERMs, followed by a SIGKILL!

regards

Matt

==============================================
Matthew Studley

The Intelligent Computer Systems Centre
Faculty of Computing, Engineering and Mathematical Sciences
Coldharbour Lane, Frenchay
BS16 1QY
United Kingdom




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-07-22 20:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-09 19:16 what causes SIGTERMs? Jad Saklawi
  -- strict thread matches above, loose matches on Subject: below --
2003-07-08 13:17 Matthew Studley
2003-07-08 13:26 ` Francis Lau
2003-07-08 14:27 ` Glynn Clements
2003-07-09 15:36   ` Matthew Studley
2003-07-10  2:12     ` Glynn Clements
2003-07-22 14:54     ` Matthew Studley
2003-07-22 15:11       ` Jan-Benedict Glaw
2003-07-22 20:47         ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).