If you were designing a standard library of a high level language (like Rust, C++, etc.) what would it do if while getting the current time of day (e.g. SystemTime::now()) it encountered a failed kernel system call (e.g. to clock_gettime) and why?

What do you think the existing implementations do?

  • Return error or raise exception
  • Return 0
  • Return undefined values (like stack garbage)
  • Panic/crash/segfault
  • hades@programming.devOP
    link
    fedilink
    arrow-up
    1
    ·
    19 days ago

    Uninitialized automatic variables. E.g. (in C/C++):

    int get_time() {
      int time;
      syscall(/* something that fails */, &time);
      return time;
    }