strace
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <error.h>
int main()
{
struct timespec tpset, tsreset;
if (clock_gettime(CLOCK_REALTIME, &tsreset) != 0) {
perror("clock_gettime() did not return success\n");
}
tpset.tv_sec = 0;
tpset.tv_nsec = 0;
clock_settime(CLOCK_REALTIME, &tpset);
perror("clock_settime");
}
#include <time.h>
#include <stdint.h>
#include <error.h>
int main()
{
struct timespec tpset, tsreset;
if (clock_gettime(CLOCK_REALTIME, &tsreset) != 0) {
perror("clock_gettime() did not return success\n");
}
tpset.tv_sec = 0;
tpset.tv_nsec = 0;
clock_settime(CLOCK_REALTIME, &tpset);
perror("clock_settime");
}
linux-91ll:/home # ./clock_settime
使用starce ./clock_settime 的结果,可以很容易看出failed在哪里