Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!umd5!decuac!felix!chuck From: chuck@felix.UUCP Newsgroups: comp.unix.ultrix Subject: Re: Ultrix 2.0 executable dumps core on 1.2 Message-ID: <13284@felix.UUCP> Date: Wed, 18-Nov-87 12:04:36 EST Article-I.D.: felix.13284 Posted: Wed Nov 18 12:04:36 1987 Date-Received: Sat, 21-Nov-87 06:32:59 EST References: <12683@felix.UUCP> Sender: chuck@felix.UUCP Reply-To: gwyn@brl-smoke.arpa (Doug Gwyn ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 61 Approved: zemon@felix.UUCP Reply-Path: In article <12683@felix.UUCP> mark@applix.UUCP (Mark Fox) writes: >2) Will subsequent versions of Ultrix simply return an error to a > "Bad system call" or will they continue to rudely and inexcusably dump > core? Really, dumping core is a bug not a feature, isn't it? Ahem -- I suspect that a SIGSYS was generated, and since you didn't establish a signal handler for it, you got the default action, which is "abnormal termination with actions" (in POSIX parlance). An example of how to recover from unsupported system calls, extracted from my getdents() system call emulation for "random UNIX variants", follows; it can be adapted to deal with other cases where there is a C library system call hook but where it is not certain that the target system's kernel will support the system call: #include extern int _getdents(); /* actual system call */ static enum { maybe, no, yes } state = maybe; /* does _getdents() work? */ /*ARGSUSED*/ static void sig_catch( sig ) int sig; /* must be SIGSYS */ { state = no; /* attempted _getdents() faulted */ } int getdents( fildes, buf, nbyte ) /* returns # bytes read; 0 on EOF, -1 on error */ int fildes; /* directory file descriptor */ char *buf; /* where to put the (struct dirent)s */ unsigned nbyte; /* size of buf[] */ { ... switch ( state ) { void (*shdlr)(); /* entry SIGSYS handler */ register int retval; /* return from _getdents() if any */ case yes: /* _getdents() is known to work */ return _getdents( fildes, buf, nbyte ); case maybe: /* first time only */ shdlr = signal( SIGSYS, sig_catch ); retval = _getdents( fildes, buf, nbyte ); /* try it */ (void)signal( SIGSYS, shdlr ); if ( state == maybe ) /* SIGSYS did not occur */ { state = yes; /* so _getdents() must have worked */ return retval; } /* else fall through into emulation */ /* case no: /* fall through into emulation */ } ...