linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* simple daemon dies
@ 2002-05-29  8:39 Sindunata
  2002-05-29  9:29 ` Glynn Clements
  0 siblings, 1 reply; 4+ messages in thread
From: Sindunata @ 2002-05-29  8:39 UTC (permalink / raw)
  To: linux-c-programming

Hi all,

I'm trying to write a simple daemon background process.
It connects to PostgreSQL and wait for a notify event and upon receiving
some event will invoke some URL using curl library.

I got it working already if I run it in foreground. But if I put the
process in background (using &), and then after sometime the process
will die. I think there's some signal that I need to catch, can
someone please help me?

Currently i'm trapping the following signals:

  struct sigaction act;
  
  /* set signal handler TERM (terminate by kill) & INT (keyboard break) to exit nicely */
  act.sa_flags = 0;
  act.sa_handler = mainExit;
  sigemptyset (&(act.sa_mask));
  
  sigaction (SIGTERM, &act, NULL);
  sigaction (SIGINT, &act, NULL);

  /* ignore SIGHUP  & SIGTTOU */
  act.sa_handler = SIG_IGN;
  sigaction(SIGHUP, &act, NULL);
  sigaction(SIGTTOU, &act, NULL);

TIA & regards,
Sindu

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

end of thread, other threads:[~2002-05-30  5:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-29  8:39 simple daemon dies Sindunata
2002-05-29  9:29 ` Glynn Clements
2002-05-30  2:16   ` Sindunata
2002-05-30  5:24     ` 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).