On Thu, 28 Oct 2004, Bruce Momjian wrote:

> Date: Thu, 28 Oct 2004 19:58:56 -0400 (EDT)
> From: Bruce Momjian <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Cc: Tom Lane <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Subject: Re: [HACKERS] Unixware 714 pthreads
>
> [EMAIL PROTECTED] wrote:
> > I agree with all that you say Tom, I'm just asking for some help to debug
> > this, Now that Larry is a litle off the list, I'm feeling really lonely on
> > UW.
> > SCO won't do anything until I come up with a test program that fails. All
> > my tries did work until then.
> >
> > I use other threaded progs like postfix or bind that nether fail.
> >
> > I'm really at lost. Would you/someone help me?
>
> The problem is that we are then spending our time debugging Unixware
> problems rather than focusing on our database software.  I think this is
> why few have offered assistance.
>
>
I understand your concerns, OTOH you all spend quite a lot of time
debugging windows...

Anyway, the little program attached does more or less what postgresql does
in term of sigaction and setitimer (Yes, unixware DOES have posix signals)
and works like a charm wether compiled with or without pthreads.

Regards
 --
Olivier PRENANT                 Tel: +33-5-61-50-97-00 (Work)
6, Chemin d'Harraud Turrou           +33-5-61-50-97-01 (Fax)
31190 AUTERIVE                       +33-6-07-63-80-64 (GSM)
FRANCE                          Email: [EMAIL PROTECTED]
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/time.h>
extern int errno;

main()
{
  sigset_t      UnBlockSig,
    BlockSig,
    AuthBlockSig;
  

  struct sigaction act,
    oact;
  void handler();

  sigemptyset(&UnBlockSig);
  sigfillset(&BlockSig);
  sigfillset(&AuthBlockSig);
  
        /*
         * Unmark those signals that should never be blocked. Some of these
         * signal names don't exist on all platforms.  Most do, but might as
         * well ifdef them all for consistency...
         */
#ifdef SIGTRAP
  sigdelset(&BlockSig, SIGTRAP);
  sigdelset(&AuthBlockSig, SIGTRAP);
#endif
#ifdef SIGABRT
  sigdelset(&BlockSig, SIGABRT);
  sigdelset(&AuthBlockSig, SIGABRT);
#endif
#ifdef SIGILL
  sigdelset(&BlockSig, SIGILL);
  sigdelset(&AuthBlockSig, SIGILL);
#endif
#ifdef SIGFPE
  sigdelset(&BlockSig, SIGFPE);
  sigdelset(&AuthBlockSig, SIGFPE);
#endif
#ifdef SIGSEGV
  sigdelset(&BlockSig, SIGSEGV);
  sigdelset(&AuthBlockSig, SIGSEGV);
#endif
#ifdef SIGBUS
  sigdelset(&BlockSig, SIGBUS);
  sigdelset(&AuthBlockSig, SIGBUS);
#endif
#ifdef SIGSYS
  sigdelset(&BlockSig, SIGSYS);
  sigdelset(&AuthBlockSig, SIGSYS);
#endif
#ifdef SIGCONT
  sigdelset(&BlockSig, SIGCONT);
  sigdelset(&AuthBlockSig, SIGCONT);
#endif
#ifdef SIGTERM
  sigdelset(&AuthBlockSig, SIGTERM);
#endif
#ifdef SIGQUIT
  sigdelset(&AuthBlockSig, SIGQUIT);
#endif
#ifdef SIGALRM
  sigdelset(&AuthBlockSig, SIGALRM);
#endif
  act.sa_handler = handler;
  sigemptyset(&act.sa_mask);
  act.sa_flags = 0;
  //  if (signo != SIGALRM)
  //  act.sa_flags |= SA_RESTART;
  /* #ifdef SA_NOCLDSTOP
  if (signo == SIGCHLD)
    act.sa_flags |= SA_NOCLDSTOP;
    #endif */
  if (sigaction(SIGALRM, &act, &oact) < 0)
    fprintf(stderr, "sigaction failed, errno = %d\n",errno);
  handler(0);
  for (;;)
    ;
}

void handler(sig)
{

  struct itimerval timeval;

  memset(&timeval,0,sizeof(struct itimerval));
  timeval.it_value.tv_sec=5;
  timeval.it_value.tv_usec=0;
  if (setitimer(ITIMER_REAL,&timeval,NULL) < 0)
    fprintf(stderr, "could not set itimer errono =  %d\n");
  printf("caught sig %d\n",sig);
}
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to