OK. I know this sounds like a really basic question, and I’ve been doing this sort of work for years. But this situation has never come up before because in the past I’ve always been able to rely on other ways to verify program results. But we’re in the process of implementing a new scheduling package so I need to know how to do this.
No, it’s definitely a shell thing. It’s just that $? is common to many shells. I’m not positive it works that way in csh or tcsh. It might be $status or something “more intuitive” there.
Another thing to watch out for is that only the least significant 8 (7?) bits of $? (which I believe is equal to the status value returned by wait(2)) are equal to the exit status of the process–the rest tell you what signal caused the process to exit if it was killed somehow. The only way I know of to sort this out is to use the macros from sys/wait.h, which are described in the wait(2) man page.