On Apr 30, 2008, at 4:38 PM, Robert Spykerman wrote: On Wed, Apr 30, 2008 at 12:04 PM, John Davidorff Pell <email@hidden> wrote:
... I think this is your problem. You are making a syscall. Mac OS X (aka Darwin) does not support making syscalls. This may sound ridiculous to you, but let me explain: The libSystem library can be thought of as a user-land component of the kernel. The syscall interface to the kernel changes often and is effectively undocumented. You might be able to reverse engineer it, but the next point-release will kill your code. Only libSystem can be trusted to make syscalls because, from outside-of-apple-point-of-view, libSystem is part of the kernel. Now, in real life, libSystem is obviously not part of the kernel, but it is updated in lock-step with the kernel. If a new kernel build is pushed out that has changed the syscall interface, then a new libSystem build is pushed out *in the same package*. Final answer: don't make syscalls, call the equivalent functions from libSystem.
Thanks for your advice. All valid points.
You've given me a good place to go look and see how stuff is done, I'll go find libSystem and dissect it :) Actually had a discussion along this line, about whether to call c libs or not... Ultimately we decided to stick with syscalls because of various reasons ( specificaly it could break quite a bit of code already in existence, requiring more rewriting. Apart from that, it's just... somewhat unappealing to call a c lib just to call the kernel to get the same functionality, but I can understand it may be blasphemous to some to do it any other way, heh ). The port is going well, and there are just one or two finishing touches before intensive testing.
But honestly, it's no biggie if I know where to find what I need to change with any major OS change. And it looks like this libSystem is what I need to go dig up. I hope the source is available, will go look now. As an aside, I don't know how often syscalls have changed. The vector numbers for BSD and OS X appear very similar. Surely there must be a lot of BSD code ported over to OSX XNU which makes syscalls... with more to come. I understand Apple may change these vectors at any given time, but it also may be in their interest to keep it as close to BSD as possible maybe. And that's a big maybe I guess.
Ultimately I may well rewrite the code to call c libs in future. Consider me caveat emptor'ed :) thanks again! Do appreciate it.
The fork function in particular does a *lot* more than just call the system call. If you can call the libc function, you will be a lot happier!
Ronnie |