zoukankan
html css js c++ java
linux显示shm segment信息一例
#include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> int main(void) { int segment_id; char* shared_memory; const int size = 4096; unsigned short mode; struct shmid_ds shmbuffer; segment_id = shmget(IPC_PRIVATE, size, S_IRUSR|S_IWUSR); shared_memory = (char*)shmat(segment_id, NULL, 0); sprintf(shared_memory, "shared memory"); printf("%s\n", shared_memory); if (shmctl(segment_id, IPC_STAT, &shmbuffer) == - 1) { fprintf(stderr, "Unable to access segment %d\n", segment_id); return -1; } printf("ID \t\t KEY \t MODE \t\t OWNER \t SIZE \t ATTTACHES \n"); printf("-- \t\t --- \t ---- \t\t ----- \t ---- \t --------- \n"); printf("%d \t %d \t",segment_id,shmbuffer.shm_perm.__key); mode = shmbuffer.shm_perm.mode; /** OWNER */ if (mode & 0400) printf("r"); else printf("-"); if (mode & 0200) printf("w"); else printf("-"); if (mode & 0100) printf("a"); else printf("-"); /** GROUP */ if (mode & 0040) printf("r"); else printf("-"); if (mode & 0020) printf("w"); else printf("-"); if (mode & 0010) printf("a"); else printf("-"); /** WORLD */ if (mode & 0004) printf("r"); else printf("-"); if (mode & 0002) printf("w"); else printf("-"); if (mode & 0001) printf("a"); else printf("-"); printf(" \t%4d\t",shmbuffer.shm_perm.uid); printf(" %d\t",shmbuffer.shm_segsz); printf(" %d\t",shmbuffer.shm_nattch); printf("\n%d", mode); printf("\n"); shmdt(shared_memory); shmctl(segment_id, IPC_RMID, NULL); fprintf(stdout, "\n%d", segment_id); return 0; }
查看全文
相关阅读:
Go入门笔记-22 访问sqlite3数据库
Go入门笔记-21 访问consul
Docker中sh提示符无法回退
Go入门笔记-20 访问redis
Docker进阶学习-1
Musl-libc库编译
修复 Could not find class [org.springframework.cloud.client.loadbalancer.LoadBalancerProperties]
Oracle DBLINK 简单使用
js几种escape()解码与unescape()编码
解决浏览器图片缓存问题(图片不能及时变过来)
原文地址:https://www.cnblogs.com/seebro/p/2476556.html
最新文章
mqtt学习-5 Mqtt服务器mosquitto搭建
Go入门笔记31-日期时间格式化
Linux不小心对根目录执行了chmod补救
Go入门笔记30-Syn.map使用
Go入门笔记29-Map使用
Go入门笔记28-VSCode Region折叠问题
rc.local无法执行问题
win10鼠标右键转圈问题处理
--only-same-user Only connections from the same user
ubuntu下sshd: no hostkeys available -- exiting
热门文章
Go入门笔记27-正则表达式使用
Go入门笔记-26 GoLand 提示版本不匹配
Go入门笔记-25 使用自定义Package
Ubuntu 20.04 apt-get install build-essential安装失败
Go入门笔记-24 Post数据
Docker进阶学习-2 swarm overlay测试
ubuntu20.04设置动态ip,静态Ip
使用Tap网络防止虚拟机桥接模式网段改变
linux查看gpio状态
Go入门笔记-23 unix域套接字通讯
Copyright © 2011-2022 走看看