It'd be nice if you could throw this in util.c. That's where most of the OS-specific functions live.