On Fri, Jan 3, 2025 at 5:32 AM Zhaoming Luo <zhming...@163.com> wrote:
> > in the latter case, you should get MIG_BAD_ID from the kernel, so you
> > can detect that.
> What's the best way to handle the MIG_BAD_ID case. I tried perror(NULL)
> but it gave my output '(ipc/mig) bad request message ID'. To be honest I
> don't think it's a very useful output. Is there a better option?

MIG_BAD_ID (in response to host_get_uptime64) means the version of
Mach in use doesn't have your work on the monotonic clock. So you
should return an appropriate Unix error, which according to POSIX
would be "EINVAL: The clock_id argument does not specify a known
clock". So either:

if (err == MIG_BAD_ID)
  {
    /* Not supported by the running kernel.  */
    errno = EINVAL;
    return -1;
  }

or you could just 'break;' out of the switch as if nothing happened,
and have the default case below do the same for you.

Sergey

Reply via email to