[comp.lang.eiffel] Catching signals

cwc@blitz.princeton.edu (Chris Clifton) (07/10/90)

I am trying to deal with an external signal in a rescue clause.
Basically the code is as follows:

rescue
  if exception = Sighup then
    ignore(Sighup); -- One is enough.
    signalled := true;
    retry
   end

This works fine when compiled with es -d, even with no assertion checking.
However, when I generate a package the rescue clause is ignored:  the program
terminates with the following message:

  Following information could be incomplete or untrustworthy.

  System execution failed.
  Below is the sequence of recorded exceptions:
  ----------------------------------------------------------------------------
  Object Class        Routine            Nature of exception            Effect
  ----------------------------------------------------------------------------
                                         External event:
                                         Hangup.                        Fail
  ----------------------------------------------------------------------------
  For more information on the last exception,
  recompile with option PRECONDITIONS or ALL_ASSERTIONS on.

Anyone have any suggestions on what this might be and how to fix it?

-Chris Clifton (cwc@Princeton.EDU)

jp@eiffel.UUCP (Jean-Pierre Sarkis) (07/24/90)

Chris Clifton (935@rossignol.Princeton.EDU) wrote:

>I am trying to deal with an external signal in a rescue clause.
>Basically the code is as follows:
>
>rescue
> if exception = Sighup then
>	ignore(Sighup); -- One is enough.
>	signalled := true;
>	retry
> end
>
>This works fine when compiled with es -d, even with no assertion checking.
>However, when I generate a package the rescue clause is ignored:  the program
>terminates with the following message:

>  Following information could be incomplete or untrustworthy.

>  System execution failed.
>  Below is the sequence of recorded exceptions:
>  ----------------------------------------------------------------------------
>  Object Class        Routine            Nature of exception            Effect
>  ----------------------------------------------------------------------------
>                                         External event:
>                                         Hangup.                        Fail
>  ----------------------------------------------------------------------------
>  For more information on the last exception,
>  recompile with option PRECONDITIONS or ALL_ASSERTIONS on.
>
>Anyone have any suggestions on what this might be and how to fix it?


	This bug has been fixed in our current development version.
The following will patch the run-time in Eiffel 2.2B in order
to handle exceptions properly when the system is compiled
with no assertion checking and post-processed.

PATCH:
-----

1)	DO a BACKUP of the directory $INSTALLATION/Eiffel/files

2)	Edit the file $INSTALLATION/Eiffel/files/_eiffel.c
	and modify the C routine rout_conv() as following:

        ********************** START *********************
static void rout_conv (rout_nm, classnum, routnum)
char  *rout_nm;
int   classnum, routnum;
{
   if (routnum<=NO_ROUT)
      sprintf (rout_nm, "%s", " ");
   else
      if (routnum==CREATE_ROUT)
         sprintf (rout_nm, "%s", "create");
      else
         if (routnum==PUT_ROUT)
            sprintf (rout_nm, "%s", "put");
         else
            if (routnum==AT_ROUT)
               sprintf (rout_nm, "%s", "item");
            else
               if (Rout_names [classnum] && Rout_names [classnum][routnum])
                  sprintf (rout_nm, "%s", Rout_names [classnum] [routnum]);
               else
                  sprintf (rout_nm, "(NULL)");
}
        ********************** END *********************************
The modification is on the line 
	"if (Rout_names [classnum] && Rout_names [classnum][routnum])"

3)	Save the file and generate the new run_time archive:

	(Check the CFLAGS in makefile _makeD: 
		-O -DBSD or -O -DSYSTEMV depending on your Unix system)

	execute:
		make -f _makeD

4)	Recompile your application with the post-processor turned ON.



Jean-Pierre SARKIS
jp@eiffel.com
(Technical support: eiffel@eiffel.com)
-- 
Jean-Pierre SARKIS
Interactive Software Engineering

Reply-to: eiffel@eiffel.com

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (07/24/90)

In article <375@eiffel.UUCP>, jp@eiffel.UUCP (Jean-Pierre Sarkis) writes:
> PATCH:
> static void rout_conv(rout_nm, classnum, routnum)
> char  *rout_nm;
>... sprintf(rout_nm, "%s", " ");
>... sprintf(rout_nm, "%s", "create");
>... sprintf(rout_nm, "%s", "put");
>... sprintf(rout_nm, "%s", "item");
>... sprintf(rout_nm, "%s", Rout_names[classnum][routnum]);
>... sprintf(rout_nm, "(NULL)");

I suppose this is more of a comp.lang.c question than a comp.lang.eiffel
question, but what do the calls to sprintf() here buy you that calls to
strcpy() wouldn't?
-- 
Science is all about asking the right questions.  | ok@goanna.cs.rmit.oz.au
I'm afraid you just asked one of the wrong ones.  | (quote from Playfair)

rick@tetrauk.UUCP (Rick Jones) (07/25/90)

In article <3463@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>In article <375@eiffel.UUCP>, jp@eiffel.UUCP (Jean-Pierre Sarkis) writes:
>> ...
>>... sprintf(rout_nm, "%s", " ");
>>... etc
>
>I suppose this is more of a comp.lang.c question than a comp.lang.eiffel
>question, but what do the calls to sprintf() here buy you that calls to
>strcpy() wouldn't?

The answer is "not a lot".  I re-worked the exception handling in _eiffel.c in
my version (and a few of the other run-time things as well).  Changing this
stuff into strcpy's was one of the more trivial fixes.  ISE have a copy of all
my changes, so I hope they'll include them in future versions.

Although I'm a devotee of Eiffel, I found the quality of the run-time C code
one of the main dissapointments of the product.  Hopefully it will improve.
It seems to show that to get a quality implementation of the Eiffel language
and environment still needs a good C programmer.  There must be a moral in this
somewhere ...

-- 
Rick Jones					You gotta stand for something
Tetra Ltd.  Maidenhead, Berks			Or you'll fall for anything
rick@tetrauk.uucp (...!ukc!tetrauk.uucp!rick)	     - John Cougar Mellencamp