Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!ucbcad!ucbvax!decvax!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: news.software.b,comp.lang.c Subject: Re: News for Xenix on PC AT ? Message-ID: <17435@sun.uucp> Date: Mon, 27-Apr-87 14:27:45 EDT Article-I.D.: sun.17435 Posted: Mon Apr 27 14:27:45 1987 Date-Received: Wed, 29-Apr-87 00:47:11 EDT References: <18346@ucbvax.BERKELEY.EDU> <145@sds.UUCP> <17005@sun.uucp> <2440@ulysses.homer.nj.att.com> <148@sds.UUCP> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 32 Xref: utgpu news.software.b:532 comp.lang.c:1858 >Signal() returns a pointer to a function; in the event of an error, -1 is >returned, not 0. As far as I know, all other functions that return a >pointer, return 0 on error. This seems to imply that 0 may be a valid >function address; No, you're inferring (incorrectly) that 0 may be a valid function address. >not being familiar with UNIX internals, I can't say for certain, but other >O/S's load programs such that they regard their starting address as 0. As UNIX is a portable operating system, it is not meaningful to ask whether UNIX loads programs such that they regard their starting address as 0. Some implementations do, some don't. (Ours doesn't.) However, just because a UNIX implementation loads a program such that it regards its starting address as 0 does NOT mean that the address of any function known to C within that program is necessarily 0. In fact, a C implementation is obliged to do whatever is necessary to ensure that no function in a program will have the address 0; a "nop" or a "br .+N" at location 0 should be sufficient. >On the other hand, if 0 cannot be a valid function address, why does >signal not return 0 on error? I would be curious to know. Because: 1) other system calls return -1 on error (including a System V shared memory call that returns a pointer); 2) the special signal value for "this signal is not caught" is usually a null pointer, so a call to "signal" that is successful can return a null pointer.