JM プロジェクトは、主に Linux 関連のマニュアルページの日本語ページを翻訳・公開しています。
... #include < semaphore.h > #include < sys/stat.h > #include < stdio.h > #include < stdlib.h > #include < unistd.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) #define BUF_SIZE 1024 /* Maximum size for exchanged string */ /* ... ze to the size of our structure */ int fd = shm_open(shmpath, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); if (fd == -1) errExit("shm_open"); if (ftruncate(fd, sizeof(struct shmbuf)) == -1) errExit("ftruncate"); /* Map the object into the caller's add ... ace */ struct shmbuf *shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shmp == MAP_FAILED) errExit("mmap"); /* Initialize semaphores as process-shared, with value 0 */ if (sem_init(&shmp->sem1, 1, 0) == -1) errExit("sem_i ... ... #include < semaphore.h > #include < sys/stat.h > #include < stdio.h > #include < stdlib.h > #include < unistd.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) #define BUF_SIZE 1024 /* Maximum size for exchanged string */ /* ... ze to the size of our structure */ int fd = shm_open(shmpath, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); if (fd == -1) errExit("shm_open"); if (ftruncate(fd, sizeof(struct shmbuf)) == -1) errExit("ftruncate"); /* Map the object into the caller's add ... ace */ struct shmbuf *shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shmp == MAP_FAILED) errExit("mmap"); /* Initialize semaphores as process-shared, with value 0 */ if (sem_init(&shmp->sem1, 1, 0) == -1) errExit("sem_i ... ... h > #include < sys/shm.h > #include < sys/sem.h > #include < stdio.h > #include < stdlib.h > #include < string.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) union semun { /* Used in calls to semctl() */ int val; struct sem ... ry and semaphore set containing one semaphore */ shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); /* Attach shared memory i ... nto our address space */ addr = shmat(shmid, NULL, SHM_RDONLY); if (addr == (void *) -1) errExit("shmat"); /* Initialize semaphore 0 in set with value 1 */ arg.val = 1; if (semctl(semid, 0, SETVAL, arg) == -1) errExit(" ... ... h > #include < sys/shm.h > #include < sys/sem.h > #include < stdio.h > #include < stdlib.h > #include < string.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) union semun { /* Used in calls to semctl() */ int val; struct sem ... ry and semaphore set containing one semaphore */ shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); /* Attach shared memory i ... nto our address space */ addr = shmat(shmid, NULL, SHM_RDONLY); if (addr == (void *) -1) errExit("shmat"); /* Initialize semaphore 0 in set with value 1 */ arg.val = 1; if (semctl(semid, 0, SETVAL, arg) == -1) errExit(" ... ... h > #include < sys/shm.h > #include < sys/sem.h > #include < stdio.h > #include < stdlib.h > #include < string.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) union semun { /* Used in calls to semctl() */ int val; struct sem ... ry and semaphore set containing one semaphore */ shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600); if (shmid == -1) errExit("shmget"); /* Attach shared memory i ... nto our address space */ addr = shmat(shmid, NULL, SHM_RDONLY); if (addr == (void *) -1) errExit("shmat"); /* Initialize semaphore 0 in set with value 1 */ arg.val = 1; if (semctl(semid, 0, SETVAL, arg) == -1) errExit(" ... ... < errno.h > #include < aio.h > #include < signal.h > #define BUF_SIZE 20 /* Size of buffers for read operations */ #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0) struct ioRequest { /* Application-defined structure for tracking I/ ... eqs = argc - 1; /* Allocate our arrays */ struct ioRequest *ioList = calloc(numReqs, sizeof(*ioList)); if (ioList == NULL) errExit("calloc"); struct aiocb *aiocbList = calloc(numReqs, sizeof(*aiocbList)); if (aiocbList == NULL) errExit("calloc"); /* Est ... sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); sa.sa_handler = quitHandler; if (sigaction(SIGQUIT, &sa, NULL) == -1) errExit("sigaction"); sa.sa_flags = SA_RESTART | SA_SIGINFO; sa.sa_sigaction = aioSigHandler; if (sigaction(IO_SIGNAL, &sa, NULL) ... ... tl.h > #include < stdio.h > #include < stdlib.h > #include < unistd.h > #include < errno.h > #include < string.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) int main(int argc, char *argv[]) { struct file_handle *fhp; int m ... E); } pathname = argv[1]; /* file_handle 構造体を確保する */ fhsize = sizeof(*fhp); fhp = malloc(fhsize); if (fhp == NULL) errExit("malloc"); /* name_to_handle_at() を最初に呼び出して ファイルハンドルに必要なサイズを入手する */ dirfd = AT_FDCWD; /* For ... */ fhsize = sizeof(*fhp) + fhp->handle_bytes; fhp = realloc(fhp, fhsize); /* Copies fhp->handle_bytes */ if (fhp == NULL) errExit("realloc"); /* コマンドラインで指定されたパス名からファイルハンドルを取得 */ if (name_to_handle_at(dirfd, pathname, fhp, & ... ... tl.h > #include < stdio.h > #include < stdlib.h > #include < unistd.h > #include < errno.h > #include < string.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) int main(int argc, char *argv[]) { struct file_handle *fhp; int m ... E); } pathname = argv[1]; /* file_handle 構造体を確保する */ fhsize = sizeof(*fhp); fhp = malloc(fhsize); if (fhp == NULL) errExit("malloc"); /* name_to_handle_at() を最初に呼び出して ファイルハンドルに必要なサイズを入手する */ dirfd = AT_FDCWD; /* For ... */ fhsize = sizeof(*fhp) + fhp->handle_bytes; fhp = realloc(fhp, fhsize); /* Copies fhp->handle_bytes */ if (fhp == NULL) errExit("realloc"); /* コマンドラインで指定されたパス名からファイルハンドルを取得 */ if (name_to_handle_at(dirfd, pathname, fhp, & ... ... pthread.h > #include < malloc.h > #include < errno.h > static size_t blockSize; static int numThreads, numBlocks; #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) static void * thread_func(void *arg) { int tn = (int) arg; /* The ... d) allocates a different amount of memory */ for (int j = 0; j < numBlocks; j++) if (malloc(blockSize * (2 + tn)) == NULL) errExit("malloc-thread"); sleep(100); /* Sleep until main thread terminates */ return NULL; } int main(int argc, char *argv[]) { i ... (argv[3]); sleepTime = (argc > 4) ? atoi(argv[4]) : 0; pthread_t *thr = calloc(numThreads, sizeof(*thr)); if (thr == NULL) errExit("calloc"); printf("============ Before allocating blocks ============\n"); malloc_info(0, stdout); /* Create threads that ... ... an.h > #include < fcntl.h > #include < stdlib.h > #include < unistd.h > #include < string.h > #include < stdio.h > #define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \ } while (0) int main(int argc, char *argv[]) { int fd; unsigned int seals; ch ... anonymous file in tmpfs; allow seals to be placed on the file */ fd = memfd_create(name, MFD_ALLOW_SEALING); if (fd == -1) errExit("memfd_create"); /* Size the file as specified on the command line */ if (ftruncate(fd, len) == -1) errExit("truncate"); p ... |= F_SEAL_FUTURE_WRITE; if (strchr(seals_arg, 'S') != NULL) seals |= F_SEAL_SEAL; if (fcntl(fd, F_ADD_SEALS, seals) == -1) errExit("fcntl"); } /* Keep running, so that the file created by memfd_create() continues to exist */ pause(); exit(EXIT_SUCCESS); ... 日本語の文書やマニュアルを配布している個人/プロジェクトへのリンクです。