~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/pkg/runtime/signal_unix.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include "runtime.h"
8
8
#include "defs_GOOS_GOARCH.h"
9
9
#include "os_GOOS.h"
 
10
#include "signal_unix.h"
10
11
 
11
12
extern SigTab runtime·sigtab[];
12
13
 
21
22
                t = &runtime·sigtab[i];
22
23
                if((t->flags == 0) || (t->flags & SigDefault))
23
24
                        continue;
 
25
 
 
26
                // For some signals, we respect an inherited SIG_IGN handler
 
27
                // rather than insist on installing our own default handler.
 
28
                // Even these signals can be fetched using the os/signal package.
 
29
                switch(i) {
 
30
                case SIGHUP:
 
31
                case SIGINT:
 
32
                        if(runtime·getsig(i) == SIG_IGN) {
 
33
                                t->flags = SigNotify | SigIgnored;
 
34
                                continue;
 
35
                        }
 
36
                }
 
37
 
 
38
                t->flags |= SigHandling;
24
39
                runtime·setsig(i, runtime·sighandler, true);
25
40
        }
26
41
}
28
43
void
29
44
runtime·sigenable(uint32 sig)
30
45
{
31
 
        int32 i;
32
 
        SigTab *t;
33
 
 
34
 
        for(i = 0; i<NSIG; i++) {
35
 
                // ~0 means all signals.
36
 
                if(~sig == 0 || i == sig) {
37
 
                        t = &runtime·sigtab[i];
38
 
                        if(t->flags & SigDefault) {
39
 
                                runtime·setsig(i, runtime·sighandler, true);
40
 
                                t->flags &= ~SigDefault;  // make this idempotent
41
 
                        }
42
 
                }
 
46
        SigTab *t;
 
47
 
 
48
        if(sig >= NSIG)
 
49
                return;
 
50
 
 
51
        t = &runtime·sigtab[sig];
 
52
        if((t->flags & SigNotify) && !(t->flags & SigHandling)) {
 
53
                t->flags |= SigHandling;
 
54
                if(runtime·getsig(sig) == SIG_IGN)
 
55
                        t->flags |= SigIgnored;
 
56
                runtime·setsig(sig, runtime·sighandler, true);
 
57
        }
 
58
}
 
59
 
 
60
void
 
61
runtime·sigdisable(uint32 sig)
 
62
{
 
63
        SigTab *t;
 
64
 
 
65
        if(sig >= NSIG)
 
66
                return;
 
67
 
 
68
        t = &runtime·sigtab[sig];
 
69
        if((t->flags & SigNotify) && (t->flags & SigHandling)) {
 
70
                t->flags &= ~SigHandling;
 
71
                if(t->flags & SigIgnored)
 
72
                        runtime·setsig(sig, SIG_IGN, true);
 
73
                else
 
74
                        runtime·setsig(sig, SIG_DFL, true);
43
75
        }
44
76
}
45
77
 
66
98
os·sigpipe(void)
67
99
{
68
100
        runtime·setsig(SIGPIPE, SIG_DFL, false);
69
 
        runtime·raisesigpipe();
 
101
        runtime·raise(SIGPIPE);
 
102
}
 
103
 
 
104
void
 
105
runtime·crash(void)
 
106
{
 
107
#ifdef GOOS_darwin
 
108
        // OS X core dumps are linear dumps of the mapped memory,
 
109
        // from the first virtual byte to the last, with zeros in the gaps.
 
110
        // Because of the way we arrange the address space on 64-bit systems,
 
111
        // this means the OS X core file will be >128 GB and even on a zippy
 
112
        // workstation can take OS X well over an hour to write (uninterruptible).
 
113
        // Save users from making that mistake.
 
114
        if(sizeof(void*) == 8)
 
115
                return;
 
116
#endif
 
117
 
 
118
        runtime·setsig(SIGABRT, SIG_DFL, false);
 
119
        runtime·raise(SIGABRT);
70
120
}