c++ - 为什么 timer_create 在 solaris 10 中为 SIGEV_THREAD 抛出错误?

标签 c++ c timer signals solaris-10

我写了一段通过使用 timer_create 来设置定时器来调用一个线程,在该线程中我将 sigev_notify 设置为 SIGEV_THREAD,它给我错误 EINVAL(无效参数)但是当我将 sigev_notify 设置为 SIGEV_SIGNAL 代码时工作正常。

我的这段代码在所有操作系统中都有效,即使是在 solaris 11 中,但对于 solaris 10 给我错误。

代码如下:

{
int status =0;
struct itimerspec ts;
struct sigevent se;

se.sigev_notify = SIGEV_THREAD;
se.sigev_value.sival_int = val;
se.sigev_notify_function = func;
se.sigev_notify_attributes = NULL;

status = timer_create(CLOCK_REALTIME, &se, timer_id);

ts.it_value.tv_sec = abs(delay);
ts.it_value.tv_nsec = (delay-abs(delay)) * 1e09;
ts.it_interval.tv_sec = abs(interval);
ts.it_interval.tv_nsec = (interval-abs(interval)) * 1e09;

status = timer_settime(*timer_id, 0, &ts, 0);

请帮我解决这个问题。

提前致谢...

最佳答案

根据 this man-page Solaris 10 不知道 SIGEV_THREAD,但只知道

The sigev_notify member specifies the notification mechanism to use when an asynchronous event occurs. The sigev_notify member may be defined with the following values:

SIGEV_NONE

No asynchronous notification is delivered when the event of interest occurs.

SIGEV_SIGNAL

A queued signal, with its value application-defined, is generated when the event of interest occurs.

SIGEV_PORT

An asynchronous notification is delivered to an event port when the event of interest occurs. The sival_ptr member points to a port_notify_t structure (see port_associate(3C)). The event port identifier as well as an application-defined cookie are part of the port_notify_t structure

关于c++ - 为什么 timer_create 在 solaris 10 中为 SIGEV_THREAD 抛出错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47989417/

相关文章:

c - 在运行时启动宏

android - 如何打破 CountDownTimer

java - 在特定时间后中断迭代的最佳方法是什么?

c++ - 在哪里可以为开源项目创建免费的符号服务器?

c# - 如何在 C++ 中为仿函数之类的 C# 容器应用算法?

C 编程初学者(数组)

c - 由于数组目前对我来说很复杂,如何在不使用数组的情况下解决问题?

javascript - 在 SetInterval 函数之外更新变量值

c++ - 在 C 中将一个数组中的字符连接到另一个数组

c++ - 如何在多显示器设置中测试我的 Windows 应用程序?