Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: thanks for "down" answers Keywords: aack thppt Message-ID: <720@auspex.UUCP> Date: 15 Dec 88 18:37:53 GMT References: <9142@smoke.BRL.MIL> <685@auspex.UUCP> <1886@loral.UUCP> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 27 >It gets worse. 2-3 weeks ago one of my instructors decided to explain >fork, exec, and waits. In all his examples he used wait ( (char *) 0). >I pointed out to him that wait wanted an address in which to stuff a result, >and using 0 was probably not a good idea. His reply was 'thats how it is >in my manual', after a few minutes of discussion it got upgraded to 'I tried >it on my system and it works'. So, Chris, Doug, and Henry, prepare yourself >for 30 or so bright and eager new programmers who will think >'wait ((char *) 0)' is the preferred way to do things. No, if you're not interested in the return status of the process for which you're waiting, and you're running on a UNIX system more recent than, say, V6, the preferred way of doing this is wait((int *)0) not wait((char *)0) If the manual says "char *", it's wrong. (Yes, I know about BSD's "union wait"; it was a dumb idea, and the BSD *kernel* still thinks it's supposed to be a pointer to "int".) Passing a NULL pointer is *not* an error; "wait" treats that as an indication that it is not to return the exit status. Aside from the incorrect data type, your instructor was correct.