这段代码编译报错:
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
pthread_t a;
void *thread(void *n)
{
for (; pthread_create(&a, NULL, thread, NULL) == 0;)
{
}
for (;;)
{
}
}
void *task(void *n)
{
setsid();
thread(NULL);
}
int main()
{
pthread_create(&a, NULL, task, NULL);
return 0;
}
编译器: gcc
系统: windows
这个程序的设计目的是让使用者双击编译成功后的exe后,cmd窗口退出,让用户除了用任务管理器,不能结束程序.