Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!uokmax!munnari.oz.au!metro!ipso!runxtsa!edward From: edward@runxtsa.runx.oz.au (Edward Birch) Newsgroups: comp.lang.c++ Subject: C, C++ interrupt routines (UNIX) Keywords: C,C++,signal Message-ID: <1972@runxtsa.runx.oz.au> Date: 14 Jul 90 15:06:37 GMT Organization: RUNX Unix Timeshare. Sydney, Australia. Lines: 40 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 #include 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