Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Time > Updating the System Clock

Updating the System Clock

We now look at two interfaces that update the system clock: settimeofday() and adjtime(). These interfaces are rarely used by application programs (since the system time is usually maintained by tools such as the Network Time Protocol daemon), and they require that the caller be privileged (CAP_SYS_TIME).

The settimeofday() system call performs the converse of gettimeofday() (which we described in Calendar Time): it sets the system’s calendar time to the number of seconds and microseconds specified in the timeval structure pointed to by tv.

#define _BSD_SOURCE

#include <sys/time.h>

int settimeofday(const struct timeval *tv, const struct timezone *tz);

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint