>>> The call to call_onauth should probably return the exit status of the >>> onauth script, which can be gotten after the wait(&pid) call >>> returns. And >>> instead of returning 0 for a failed call, return -1. I'm not sure >>> if we >>> care about that, but it's information that might be useful later on. >> >> personally i would go with "1" for good and "0" for bad, but i can >> see the logic here as well- just return the exit status code from wait >> () or waitpid(). as long as it's clearly documented, i can go either >> way. >> > Well, we run into a minor issue, but I think I can resolve it fairly > simply. We need to return "internal" error codes if we have problems > running the script, but we need to return "external" error codes if the > script returns non-zero. I propose that we return codes >= 256 for > "internal" errors (in the case of ENOENT or EACCES, either bit-shift them > or add 256 (probably simpler to add 256), and return "external" error > codes as-is. Either way, 0 is a success. What do you think? I'd like to > keep our APIs consistant in this manner. > <snip>
>> also, the parameter to wait() is not the address of "pid"... it's the >> address of the integer where the exit status will be stored. it >> doesn't matter right now, but after your discussion about returning >> the exit code, that makes sense- so i've added that. >> > I thought about that and figured why not reuse the existing variable, but > there's no reason not to use another one either (4 bytes of memory is > pretty cheap these days :)). > In looking at the man page for wait(), the value returned in rv is NOT the actual return code, it's bit-shifted by 256. You need to use the macro WEXITSTATUS(rv) to get the actual exit code. So we can return rv directly or unmodified E{NOENT|ACCES}, and just know that if the return value is > 256 that we have to bit-shift it back to get the actual exit code... I think that works just fine. Josh -- Joshua Megerman SJGames MIB #5273 - OGRE AI Testing Division You can't win; You can't break even; You can't even quit the game. - Layman's translation of the Laws of Thermodynamics [EMAIL PROTECTED]