2016-11-15 75 views
1

OS: Ubuntu的尝试在C++应用程序来改变实时时钟在Ubuntu 14.04,获得 “不允许操作”

版本: 14.04

语言: C++ 11

我写了一个应用程序,需要根据不同的来源更改实时时钟。作为背景,我没有使用NTP来管理这个事件的原因是基于不同时间点所需的不同时钟源,对于所有使用CLOCK_REALTIME的当前应用程序。此应用程序接收时钟参考时间并使用clock_settime设置时钟。这会返回消息Operation not permitted

if(clock_settime(CLOCK_REALTIME, &timeRT) != 0) { std::cerr << " Set clock_settime(CLOCK_REALTIME, &timeRT) = " << strerror(errno) << std::endl; }

我假定应用程序的权限设置不正确。

  • 任何方向怎么做?
  • 还有什么我应该检查的?

回答

1

运行应用程序的根目录,并试图设置时钟前,请致电:

procmgr_ability(0, PROCMGR_AID_CLOCKSET); 

您将需要包括:

#include <sys/procmgr.h> 
相关问题