runxinzhi.com
首页
百度搜索
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; }
相关阅读:
文件内容作为服务器的响应练习
request的请求体数据获取
request请求头的数据
Nodejs中流的操作
response的数据
http(二)
Android SlidingMenu使用详解
Android跨应用启动Service
Android使用PopupMenu创建弹出式菜单
HTML5 内联框架iFrame
原文地址:https://www.cnblogs.com/seebro/p/2476556.html
最新文章
XNA框架基础——总结
XNA框架基础——获取免费的XNA Game Studio Express
c#中split的用法
创建你的第一个游戏Pong——游戏构思
XNA框架基础——从头开始
XNA框架基础——XNA介绍
创建你的第一个游戏Pong——概览
创建你的第一个游戏Pong——让我们编写Pong
poj 3322 Bloxorz I 夜
poj 2823 Sliding Window 夜
热门文章
poj 1734 Sightseeing trip 夜
poj 3683 Priest John's Busiest Day 夜
poj 3648 Wedding 夜
poj 1184 聪明的打字员 夜
poj 2749 Building roads 夜
poj 2723 Get Luffy Out 夜
poj 3666 Making the Grade 夜
poj 3678 Katu Puzzle 夜
vscode用户代码片段自定义
端口和进程的区别
Copyright © 2020-2023
润新知