edward@runxtsa.runx.oz.au (Edward Birch) (07/14/90)
I am interested in some comments; am I correct with my analysis relating to
the below code, that the line `` cout << val << "\n"; '' is *very* dangerous.
#include <signal.h>
#include <stream.h>
void
func(int val)
{
// printf("%d\n", val); // C sample code
cout << val << "\n"; // C++ sample code ...
// I believe this to be invalid because
// libC.a, etc is not re-entrant
// in particular malloc() and ::new()
}
main()
{
signal(SIGINT, (PF)func);
signal(SIGQUIT, (PF)func);
// ...
}
As I understand with C++ and for that matter C the above example is
to be *avoided* because the stdio or streams library can for example
invoke routines that are not re-entrant and those routines may for
example be executing when the interrupt in question is accepted (processed).
I refer in particular to malloc() which is used by default by
::new() for example.
Edward Birch
Phone: + 61 2 958-2119
Post: GPO Box 2479, Sydney, NSW 2001, Australia
UUCP: seismo!munnari!runx.oz!edward ACSnet: edward@runx.oz
ARPA: edward%runx.oz@seismo.css.gov CSNET: edward@runx.oz