每次我在linux c++中为命名管道运行程序时,都会发出SIGSTOP信号

SIGSTOP signal everytime i run my program for named pipe in linux c++

本文关键字:程序 信号 SIGSTOP 运行 管道 linux c++      更新时间:2023-10-16

我有一个检查管道是否存在的程序,所以在一个函数中写道:

status = mkfifo("recv",0666);
fd1 = open("recv",O_WRONLY);
fd2 = open("sendd", O_RDONLY);
cout<<"we are checking botth bcz we have both read and write in the program------:)";
if(fd1 <0 && fd2 <0)
{
    //strerror(errno);
    err = 1;// a const for remote
}
else if(fd1 >0 || fd2 >0){
    err = 2; // a const for local
}
else{
    err = 3; // a const for progrm failure error
    cout<<"program has some problems";
}

但每次我运行程序时,它都会在fd1=打开("recv",O_WRONLY)处停止;称Thread1:信号SIGSTOP,尽管它只在fd2=open("sendd",O_RDONLY)下正常工作;我不知道它为什么会犯这个错误??我是linux管道的新手。

RTF,http://linux.die.net/man/3/mkfifo

一旦你用这种方式创建了一个FIFO特殊文件,任何进程都可以像普通文件一样打开它进行读取或写入。然而,它必须在两端同时打开,然后才能继续对其进行任何输入或输出操作。打开FIFO进行正常读取会阻塞,直到其他进程打开相同的FIFO进行写入,反之亦然。