Shmget: Invalid argument. Why i get this error?
来源:互联网 发布:java解决int数值上限 编辑:程序博客网 时间:2024/05/20 20:04
Question:
I get a "shmget: Invalid argument error" while i try to execute this part of code
int *nFS, *spb, *cell1, shmid; key_t key = 5768; //i need a shared memory segment in which i can put 3 ints if ((shmid = shmget(key, (sizeof(int) * 3), IPC_CREAT | 0666)) < 0 ) { perror("shmget"); exit(1); } if ((spb = (int)shmat(shmid, NULL, 0))== -1 ){ perror("shmat"); exit(1); } cell1= spb + 1 ; nFS= cell1 + 1; //i try to assign here 7 to nFS *nFS=7;
there is something wrong here but i can't figure out what. Can you help me?
Answer:
From the shmget(1) man page:
EINVAL A new segment was to be created and size < SHMMIN or size > SHMMAX, or no new segment was to be created, a segment with given key existed, but size is greater than the size of that segment.
You should check whether you still have an segment for this key using ipcs
and remove it withipcrm
.
0 0
- Shmget: Invalid argument. Why i get this error?
- shmget 返回 -1, Invalid argument
- shmget出现Invalid argument错误
- shmget报错Invalid argument
- zsim shmget出现shmget:Invalid argument错误的解决办法
- Error: Invalid argument: /X
- transfer error: Invalid argument
- accept error: Invalid argument
- Invalid argument: could not call shmget错误处理方法
- “VMware: vmw_ioctl_command error Invalid argument.
- transfer error: Invalid argument. Failed to push selection: Invalid argument
- eclipse termios.error: (22, 'Invalid argument')
- Error:dojo.data.ItemFileWriteStore:Invalid item argument
- Error while creating directories: Invalid argument
- Qt Createor error writing to -: Invalid argument
- Qt Createor error writing to -: Invalid argument
- Why does this code using `::boost::bind` get a compiler error?
- shmget创建共享内存errno=22,Invalid argument错误问题
- 阅读器订阅
- iOS基础一 UISwitch
- 好程序员和差程序员
- JQuery插件第三十八个:表单元素清空
- Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败
- Shmget: Invalid argument. Why i get this error?
- ios email 验证规则
- 八种排序算法效率比较
- sqlserver2005使用row_number() over分页的实现方法
- 猫眼移动科技:IDF14现场智能大搜查
- Ubuntu 和 Windows 配置VPN
- bzoj 1029 [JSOI2007] 建筑抢修 题解
- 由委托说明事件的由来1
- u影很惊讶