linux poxis 共享内存进程间通讯

it2025-08-04  6

一、用到的头文件及函数和系统库 1、库:unix{ LISBS += -lrt } 2、头文件: #include <sys/types.h> #include <sys/stat.h> /* For mode constants / #include <sys/mman.h> #include <fcntl.h> / For O_* constants / #include <unistd.h> 3、主要函数: int shm_open( cosnt char name, int oflag, mode_t mode); int shm_unlink( const char name); int ftruncate( int fildes, off_t lenght ); void mmap(void addr, size_t len, int prot, int flgs, int fildes, off_t off ); int munmap( void addr, size_t len ); int close( int fildes ); int fstat( int fildes, struct stat *buf ); int fchown( int fildes, uid_t owner, gid_t group ); int fchmod( int fildes, mode_t mode );

/ // class: IpcShareMem class IpcShareMem{ private: int m_shm_fd; char *m_shm_name_ptr; char *m_mmap_addr; int

最新回复(0)