~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/interfaces/libpq/pqsignal.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * pqsignal.c
 
4
 *        reliable BSD-style signal(2) routine stolen from RWW who stole it
 
5
 *        from Stevens...
 
6
 *
 
7
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 *
 
11
 * IDENTIFICATION
 
12
 *        $PostgreSQL$
 
13
 *
 
14
 * NOTES
 
15
 *              This shouldn't be in libpq, but the monitor and some other
 
16
 *              things need it...
 
17
 *
 
18
 *-------------------------------------------------------------------------
 
19
 */
 
20
#include "pqsignal.h"
 
21
 
 
22
#include <signal.h>
 
23
 
 
24
pqsigfunc
 
25
pqsignal(int signo, pqsigfunc func)
 
26
{
 
27
#if !defined(HAVE_POSIX_SIGNALS)
 
28
        return signal(signo, func);
 
29
#else
 
30
        struct sigaction act,
 
31
                                oact;
 
32
 
 
33
        act.sa_handler = func;
 
34
        sigemptyset(&act.sa_mask);
 
35
        act.sa_flags = 0;
 
36
        if (signo != SIGALRM)
 
37
                act.sa_flags |= SA_RESTART;
 
38
#ifdef SA_NOCLDSTOP
 
39
        if (signo == SIGCHLD)
 
40
                act.sa_flags |= SA_NOCLDSTOP;
 
41
#endif
 
42
        if (sigaction(signo, &act, &oact) < 0)
 
43
                return SIG_ERR;
 
44
        return oact.sa_handler;
 
45
#endif   /* !HAVE_POSIX_SIGNALS */
 
46
}