Sun Cluster 資料服務開發者指南 (適用於 Solaris 作業系統)

gettime 公用程式程式碼清單

gettime 公用程式是 PROBE 程式使用的 C 程式,用於追蹤探測的兩次重新啟動之間的時間間隔。您必須編譯此程式並將其置於與回呼方法相同的目錄中,即,由 RT_basedir 特性指向的目錄。


範例 B–4 gettime.c 公用程式

# This utility program, used by the probe method of the data service, tracks
# the elapsed time in seconds from a known reference point (epoch point). It
# must be compiled and placed in the same directory as the data service callback
# methods (RT_basedir).

#pragma ident   “@(#)gettime.c   1.1   00/05/24 SMI”

#include <stdio.h>
#include <sys/types.h>
#include <time.h>

main()
{
    printf(“%d\n”, time(0));
    exit(0);
}