Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 用于Unix/Linux C++;_C++_Linux_Winapi - Fatal编程技术网

C++ 用于Unix/Linux C++;

C++ 用于Unix/Linux C++;,c++,linux,winapi,C++,Linux,Winapi,有人知道Linux/UNIX操作系统的Windows功能吗?(特别是对于wxWidgets应用程序。)您可以使用 下面是一个例子: #include <signal.h> bool stop = false; void app_stopped(int sig) { // function called when signal is received. stop = true; } int main() { // app_stopped will be call

有人知道Linux/UNIX操作系统的Windows功能吗?(特别是对于wxWidgets应用程序。)

您可以使用

下面是一个例子:

#include <signal.h>

bool stop = false;

void app_stopped(int sig)
{
   // function called when signal is received.
   stop = true;
}

int main()
{
   // app_stopped will be called when SIGINT (Ctrl+C) is received.
   signal(SIGINT, app_stopped);

   while(false == stop)
      Sleep(10);
}
#包括
bool-stop=false;
无效应用程序_已停止(内部信号)
{
//收到信号时调用的函数。
停止=真;
}
int main()
{
//当收到SIGINT(Ctrl+C)时,将调用app_stopped。
信号(信号,应用程序停止);
while(false==停止)
睡眠(10);
}

如评论中所述,避免了一些常见于
signal()
的陷阱,应优先考虑。

到目前为止,您进行了哪些研究?据我所知,POSIX信号是最接近的匹配。或者更确切地说。inb4:@LightnessRacesinOrbit感谢您的参考,非常有用。这是一个通常一旦到位就不会被修改的东西,所以上次我这么做时,我没有听说过
sigaction