View | Details | Raw Unified | Return to bug 1000
Collapse All | Expand All

(-)a/src/core/model/simulator.cc (+24 lines)
 Lines 30-35    Link Here 
30
#include "ns3/global-value.h"
30
#include "ns3/global-value.h"
31
#include "ns3/assert.h"
31
#include "ns3/assert.h"
32
#include "ns3/log.h"
32
#include "ns3/log.h"
33
#include "ns3/fatal-impl.h"
33
34
34
#include <math.h>
35
#include <math.h>
35
#include <fstream>
36
#include <fstream>
 Lines 51-56    Link Here 
51
                                           TypeIdValue (MapScheduler::GetTypeId ()),
52
                                           TypeIdValue (MapScheduler::GetTypeId ()),
52
                                           MakeTypeIdChecker ());
53
                                           MakeTypeIdChecker ());
53
54
55
struct sigaction Simulator::m_act;
56
54
static void
57
static void
55
TimePrinter (std::ostream &os)
58
TimePrinter (std::ostream &os)
56
{
59
{
 Lines 160-165    Link Here 
160
Simulator::Run (void)
163
Simulator::Run (void)
161
{
164
{
162
  NS_LOG_FUNCTION_NOARGS ();
165
  NS_LOG_FUNCTION_NOARGS ();
166
  OverrideInterruptHandler ();
163
  GetImpl ()->Run ();
167
  GetImpl ()->Run ();
164
}
168
}
165
169
 Lines 167-172    Link Here 
167
Simulator::RunOneEvent (void)
171
Simulator::RunOneEvent (void)
168
{
172
{
169
  NS_LOG_FUNCTION_NOARGS ();
173
  NS_LOG_FUNCTION_NOARGS ();
174
  OverrideInterruptHandler ();
170
  GetImpl ()->RunOneEvent ();
175
  GetImpl ()->RunOneEvent ();
171
}
176
}
172
177
 Lines 366-372    Link Here 
366
  return GetImpl ();
371
  return GetImpl ();
367
}
372
}
368
373
374
void
375
Simulator::OverrideInterruptHandler (void)
376
{
377
  // override default SIGABRT handler 
378
  struct sigaction act;
379
  act.sa_flags = 0;
380
  sigemptyset (&act.sa_mask);
381
  act.sa_handler = InterruptHandler;
382
  sigaction (SIGINT, &act, &m_act);
383
}
369
384
385
void 
386
Simulator::InterruptHandler (int sig_num) 
387
{
388
  FatalImpl::FlushStreams ();
389
  // restore previous handler
390
  sigaction (SIGINT, &m_act, 0);
391
  // resend signal
392
  raise (SIGINT);
393
}
370
394
371
} // namespace ns3
395
} // namespace ns3
372
396
(-)a/src/core/model/simulator.h (+6 lines)
 Lines 31-36    Link Here 
31
31
32
#include <stdint.h>
32
#include <stdint.h>
33
#include <string>
33
#include <string>
34
#include <signal.h>
34
35
35
namespace ns3 {
36
namespace ns3 {
36
37
 Lines 783-788    Link Here 
783
  static EventId DoSchedule (Time const &time, EventImpl *event);
784
  static EventId DoSchedule (Time const &time, EventImpl *event);
784
  static EventId DoScheduleNow (EventImpl *event);
785
  static EventId DoScheduleNow (EventImpl *event);
785
  static EventId DoScheduleDestroy (EventImpl *event);
786
  static EventId DoScheduleDestroy (EventImpl *event);
787
788
  static void InterruptHandler (int);
789
  static void OverrideInterruptHandler (void);
790
791
  static struct sigaction m_act;
786
};
792
};
787
793
788
/**
794
/**

Return to bug 1000