我想使用SIGNAL SIGSUR1在两个进程之间进行通信,但是我得到了编译器错误:
error: ‘SIGSUR1’ was not declared in this scope .
Run Code Online (Sandbox Code Playgroud)
有什么问题?
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
void cursor(int y)
{
int i;
printf("%c[%d;%df",0x1B,y,0);
}
void handle(int fd,int turtle_current_pos){
fcntl(fd,F_SETFL,O_NONBLOCK);
write(fd,&turtle_current_pos,sizeof(int));
}
int getdist(int fd,int hare_pos,int max_dist)
{
int r,n;
raise(0,SIGSUR1);
fcntl(fd,F_SETFL,O_NONBLOCK);
if((n=read(fd,&r,sizeof(int)))){
if((hare_pos-r-max_dist)>0)
return 0;
else
return 1;
}
}
void print(char b,int a){
fflush(stdout);
if(b=='T') cursor(10);
else cursor(15);
for(int i=0;i<a;i++) printf(" ");
printf("%c\n",b);
}
void turtle(int fd,int sec1,int turtle_speed){ …Run Code Online (Sandbox Code Playgroud) c ×1