1 Star 0 Fork 0

池岸洋/Linux

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
client.cc 591 Bytes
一键复制 编辑 原始数据 按行查看 历史
池岸洋 提交于 2025-02-19 14:40 +08:00 . 共享内存
#include"share.hpp"
int main()
{
int fd = open("myfifo",O_WRONLY);
if(fd == -1)
{
log(error,"open failure: %s",strerror(errno));
exit(5);
}
//获取shamid
int shmid = Getshmid();
char* shmaddr = (char*)shmat(shmid,nullptr,0);
if((void*)shmaddr == (void*)-1)
{
log(fatal,"shamt failure: %s",strerror(errno));
return 1;
}
while(true)
{
std::cout << "Please Enter@ ";
fgets(shmaddr,SIZE_MM,stdin);
int n = write(fd,"x",sizeof(char));
}
shmdt((void*)shmaddr);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chian-ocean/linux.git
git@gitee.com:chian-ocean/linux.git
chian-ocean
linux
Linux
master

搜索帮助