| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | redirection revision |
Hi Bill, Francois, Darin, Mike, David:
Thursday, January 30 1997, you wrote to me:
BC> In order to get info into your "log" file when OS2 is
about to shut down
BC> your "appli", setup and use the SIGNAL functions.
I had some trouble with signal. Consider the next program, which
deliberately causes a segment violation (trap 005):
=============================== snip =========================================
#include
#include
#include
void emergency(int sig);
FILE *fuit;
main()
{
long a[10];
signal(SIGSEGV, emergency);
if ((fuit=fopen("test.out", "w")) == (FILE*) NULL)
{
fprintf(stderr,"File test.out cannot be opened. Sri.\n");
exit(-1);
}
a[9] = 10L;
printf("%ld \n", a[9]);
fprintf(fuit, "%ld \n", a[9]);
printf("A statement preceeding the illegal assignment\n");
fprintf(fuit, "A statement preceeding the illegal assignment\n");
a[10000] = 10L;
printf("%ld \n", a[10000]);
fprintf(fuit, "%ld \n", a[10000]);
return 0;
}
void emergency(int sig)
{
exit(1);
}
=============================== snip =========================================
Nothing spectacular.
When i compile this program using Borland C++ version 1.0, the result is:
D:\he3>bcc test.c
Borland C++ Version 1.00 Copyright (c) 1993 Borland International
test.c:
Error test.c 13: Type mismatch in parameter '__func' in call to 'signal' in
function main
Warning test.c 39: Parameter 'sig' is never used in function emergency
*** 1 errors in Compile ***
bcc nags about the type of the function emergency. Renaming it into
whatever name, makes no difference, it is not a predefined name. Using
different types (int etc.) does not change the error message. I can't find
the definition of signal in the include files, so i can't check what's
wrong. Any idea? My test.c source is a copy of the example in Borlands
manual. Borlands example, literally copied from page 285, produces the same
error message.
IBM's icc compiles my source without problems.
The results are astonishing: the mere fact that a signal function is
invoked, is sufficient to fflush the buffers both of the redirected i/o as
well as the streamed file. The trap 005 is gone, the violation remains. So
far so good. Now back to the program i want to debug...
Thanks for your help,
Henk
--- GoldED 2.50+
* Origin: Henks Toolbox, Mail only (2:286/415)SEEN-BY: 50/99 54/99 270/101 620/243 625/160 711/401 413 430 934 712/311 407 SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1 @PATH: 286/415 4 700 280/801 270/101 712/624 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.