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

gettime 公用程式

gettime 公用程式是一種 C 程式, PROBE 程式用其追蹤在探測重新啟動之間的持續時間。 您必須編譯此程式,並將其置於與回呼方法相同的目錄中,即 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);
}