GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4SocketSignalHandler.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
15 
16 
17 Int_t TGo4SocketSignalHandler::fgiLastSignal = 0; // unix signal id
18 
20 {
21  SetSignalAction(signum,enabled);
22 }
23 
25 {
26 }
27 
29 {
30  SetSignalAction(signum, 0);
31 // optional part:
32 // if(signum == SIGWINCH)
33 // {
34 // //TGo4SocketSignalHandler::fgiLastSignal = SIGWINCH;
35 // }
36 // end optional part
38  SetSignalAction(signum,1);
39 }
40 
41 #ifndef _MSC_VER
42 
43 #include <signal.h>
44 
46 {
47  SetSignalAction(SIGWINCH, enabled);
48 }
49 
50 void TGo4SocketSignalHandler::SetSignalAction(Int_t signum, Bool_t enabled)
51 {
52  struct sigaction new_action, old_action;
53 
54  /* Set up the structure to specify the new action. */
55  if (enabled)
56  new_action.sa_handler = TGo4SocketSignalHandler::Handle;
57  else
58  new_action.sa_handler = SIG_IGN;
59 
60  sigemptyset(&new_action.sa_mask);
61  new_action.sa_flags = 0;
62  sigaction(signum, nullptr, &old_action);
63  if (enabled)
64  sigaction(signum, &new_action, nullptr);
65 }
66 
68 {
69  signal(SIGPIPE, SIG_IGN);
70 }
71 
73 {
74  return GetLastSignal() == SIGWINCH;
75 }
76 
77 #else
78 
79 // do nothing in windows
80 
81 void TGo4SocketSignalHandler::SetSignalAction(Int_t signum, Bool_t enabled)
82 {
83 }
84 
86 {
87 }
88 
90 {
91 }
92 
94 {
95  return false;
96 }
97 
98 #endif
99 
101 {
102  return fgiLastSignal;
103 }
104 
106 {
107  fgiLastSignal = v;
108 }
TGo4SocketSignalHandler()=delete
static void SetLastSignal(Int_t v=0)
static void SetSigWINCH(Bool_t enabled=kTRUE)
static void SetSignalAction(Int_t signum, Bool_t enabled=kTRUE)