Sun Cluster 数据服务开发者指南(适用于 Solaris OS)

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);
}