Overview
Comment:Minor improvements to signal handling (.exe).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/merging-ode2odes-exe | trunk
Files: files | file ages | folders
SHA3-256: 80f6f8264aa8c15ddf75c015f5de45de57282210c78f86d275f2e03434f50241
User & Date: geraint@users.sourceforge.net on 2001-03-12 23:16:37
Other Links: branch diff | manifest | tags
Context
2001-03-16
03:56:13
Removed psignal/siginfo.h - problematic and unnecessary. check-in: 6848d4da90 user: geraint@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
2001-03-12
23:16:37
Minor improvements to signal handling (.exe). check-in: 80f6f8264a user: geraint@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
03:59:30
SIGINT (C-c C-c) now causes simulation data to be dumped to MTT.core.
SIGQUIT (C-c C-\) as for SIGINT, then raises default SIGQUIT.
SIGFPE as for SIGINT, then raises default SIGABRT.
check-in: 25ab7dc08c user: geraint@users.sourceforge.net tags: origin/merging-ode2odes-exe, trunk
Changes

Modified mttroot/mtt/bin/trans/make_ode2odes from [af63f110b7] to [2af7299e92].

1
2
3
4
5
6
7
8
9
10
11





12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23











+
+
+
+
+







#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
    ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.51.2.4  2001/03/12 03:59:30  geraint
## SIGINT  (C-c C-c) now causes simulation data to be dumped to MTT.core.
## SIGQUIT (C-c C-\) as for SIGINT, then raises default SIGQUIT.
## SIGFPE  as for SIGINT, then raises default SIGABRT.
##
## Revision 1.51.2.3  2001/03/07 04:06:55  geraint
## Irix: catch SIGFPE and write data before aborting (.exe).
## GNU/Linux: nada.
##
## Revision 1.51.2.2  2001/03/02 00:45:21  geraint
## Separated Euler and Implicit methods in .cc code and dependencies.
##
304
305
306
307
308
309
310

311
312
313
314
315
316
317
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323







+







#endif

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#ifdef STANDALONE
#include <csignal>
#include <siginfo.h> // for Irix psignal
#include <fstream>

extern ColumnVector F${sys}_input (
	ColumnVector &x,
	ColumnVector &y,
	const double &t,
	ColumnVector &par);
609
610
611
612
613
614
615

616
617
618
619
620
621
622
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629







+







  static Matrix data;
  static int row;

  if (dump_data)
    {
       Matrix written_data = data.extract (0, 0, row-1, data.cols ()-1);
       save_ascii_data_for_plotting (file, written_data, "MTT_data");
       return;
    }

  const int nx = x.length (), ny = y.length ();
  register int col = 0;

  if (0 == row)
    data = Matrix (nrows, 1+ny+1+nx, 0.0);
644
645
646
647
648
649
650


651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676


677
678
679
680
681
682
683
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672

673
674

675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692







+
+













-


-









+
+







#ifdef STANDALONE
void dump_data (ostream &file)
{
  ColumnVector null (0.0);
  mtt_write (0.0, null, null, 0, true, file);
}

void set_signal_handlers (void);

void handle_signal (int signum)
{
  // handle some signals to ensure data is written.
  psignal (signum, "# Writing data to MTT.core");
  ofstream corefile ("MTT.core");
  dump_data (corefile);
  switch (signum)
    {
      case SIGFPE:
        // Intel chips do not raise SIGFPE for DIVZERO :-(
        raise (SIGABRT);
        break;
      case SIGINT:
        cerr << "# Continuing." << endl;
	break;
      case SIGQUIT:
        cerr << "# Quitting." << endl;
	signal (SIGQUIT, SIG_DFL);
	raise (SIGQUIT);
	break;
      default:
        cerr << "# Warning: make_ode2odes needs updating!" << endl;
	signal (signum, SIG_DFL);
	raise (signum);
        break;
    }
  corefile.close ();
  set_signal_handlers ();
}

void set_signal_handlers (void)
{
  signal (SIGFPE,	handle_signal);
  signal (SIGINT,	handle_signal);
  signal (SIGQUIT,	handle_signal);


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]