This is svshm/svshm_lock.c, an example program file from the book The Linux Programming Interface.
This file is not printed in the book; it is a supplementary file for Chapter 48.
The source code file is copyright 2010, Michael Kerrisk, and is licensed under the GNU Affero General Public License, version 3.
In the listing below, the names of Linux system calls and C library functions are hyperlinked to manual pages from the Linux man-pages project, and the names of functions implemented in the book are hyperlinked to the implementations of those functions.
/* svshm_lock.c Lock the System V shared memory segments identified by the command-line arguments. See also svshm_unlock.c. */ #include <sys/types.h> #include <sys/shm.h> #include "tlpi_hdr.h"
int
main(int argc, char *argv[])
{
int j;
for (j = 1; j < argc; j++)
if (shmctl(getInt(argv[j], 0, "shmid"), SHM_LOCK, NULL) == -1)
errExit("shmctl");
sleep(5);
exit(EXIT_SUCCESS);
}
This page copyright (C) 2013, Michael Kerrisk, mtk AT man7.org