more on error checking (was: Complexity of reallocating storage)

Greg Hunt hunt at dg-rtp.rtp.dg.com
Wed Feb 13 01:39:40 AEST 1991


In article <1991Feb12.011911.7677 at comp.vuw.ac.nz>, duncan at comp.vuw.ac.nz (Duncan McEwan) writes:
> 
> I'm not sure if this has been discussed in this thread yet, but
> one possibility that I've seen suggested elsewhere is to have
> failing system calls generate a signal to the calling process
> (SIGSYS2 anyone?).  The default action might be to terminate the
> process, though perhaps printing a diagnostic and resuming would
> be more compatible with current behaviour.  I can't offhand think
> of any particularly nice way of implementing a libc provided default
> handler that could do the latter without messing with the compilers
> or crt0.o, etc, though.
> 
> It would be nice if such a scheme could be implemented entirely
> without kernel support (perhaps by putting the signal generating
> stuff in the libc wrappers for each system call), but I don't think
> that would allow passing a parameter to the handler (which you would
> want, to give information about what system call failed).
> 
> Hm, thinking about it, this all sounds a bit VMSish, and if its
> only aim is to provide protection from programmers who don't check
> every syscall, then its probably a non-starter :-)
>
> Comments, suggestions, flames, anyone?

I'd rather not see it myself.  I already have code in which I print out
a message when I get SIGSYS (bad argument to system call), and then
ignore the signal, thus returning control to the code that made the
bad call.  It then (supposedly) gets error EINVAL, and since I'm
checking the error returns from my system calls, I then print out
what system call I was trying to do, what error I got, and any other
information I can provide, such as the name of the file I was reading
or writing if it was a file system related call.  I do similar error
reporting for any error from any system call that my code is not
prepared to deal with (you can correctly surmise from this which side
of the "should I check error returns from system calls" debate I'm on).

You mentioned in your second paragraph that you'd want to pass such
information somehow so that the signal handler can print it out for
you.  I think it is easier to handle such errors by checking the
return from the system call.  It would also allow you to print out
a large amount of information that it might be difficult to do with
a single parameter to a signal handler.  For me, coding error handling
where the error occurs certainly makes the code easier to understand.

I agree with your last statement.  It's a non-starter.  That's my
opinion, too.

-- 
Greg Hunt                        Internet: hunt at dg-rtp.rtp.dg.com
DG/UX Kernel Development         UUCP:     {world}!mcnc!rti!dg-rtp!hunt
Data General Corporation
Research Triangle Park, NC, USA  These opinions are mine, not DG's.



More information about the Comp.unix.programmer mailing list