aboutsummaryrefslogtreecommitdiffstats
path: root/man/man2/shmop.2
diff options
context:
space:
mode:
Diffstat (limited to 'man/man2/shmop.2')
-rw-r--r--man/man2/shmop.222
1 files changed, 10 insertions, 12 deletions
diff --git a/man/man2/shmop.2 b/man/man2/shmop.2
index 12e7bd763f..660d9615ea 100644
--- a/man/man2/shmop.2
+++ b/man/man2/shmop.2
@@ -312,13 +312,11 @@ The following header file is included by the "reader" and "writer" programs:
#ifndef SVSHM_STRING_H
#define SVSHM_STRING_H
\&
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/sem.h>
\&
-#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \[rs]
- } while (0)
-\&
union semun { /* Used in calls to semctl() */
int val;
struct semid_ds *buf;
@@ -372,23 +370,23 @@ main(void)
\&
shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600);
if (shmid == \-1)
- errExit("shmget");
+ err(EXIT_FAILURE, "shmget");
\&
semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
if (semid == \-1)
- errExit("semget");
+ err(EXIT_FAILURE, "semget");
\&
/* Attach shared memory into our address space. */
\&
addr = shmat(shmid, NULL, SHM_RDONLY);
if (addr == (void *) \-1)
- errExit("shmat");
+ err(EXIT_FAILURE, "shmat");
\&
/* Initialize semaphore 0 in set with value 1. */
\&
arg.val = 1;
if (semctl(semid, 0, SETVAL, arg) == \-1)
- errExit("semctl");
+ err(EXIT_FAILURE, "semctl");
\&
printf("shmid = %d; semid = %d\[rs]n", shmid, semid);
\&
@@ -399,7 +397,7 @@ main(void)
sop.sem_flg = 0;
\&
if (semop(semid, &sop, 1) == \-1)
- errExit("semop");
+ err(EXIT_FAILURE, "semop");
\&
/* Print the string from shared memory. */
\&
@@ -408,9 +406,9 @@ main(void)
/* Remove shared memory and semaphore set. */
\&
if (shmctl(shmid, IPC_RMID, NULL) == \-1)
- errExit("shmctl");
+ err(EXIT_FAILURE, "shmctl");
if (semctl(semid, 0, IPC_RMID, dummy) == \-1)
- errExit("semctl");
+ err(EXIT_FAILURE, "semctl");
\&
exit(EXIT_SUCCESS);
}
@@ -470,7 +468,7 @@ main(int argc, char *argv[])
\&
addr = shmat(shmid, NULL, 0);
if (addr == (void *) \-1)
- errExit("shmat");
+ err(EXIT_FAILURE, "shmat");
\&
memcpy(addr, argv[3], size);
\&
@@ -481,7 +479,7 @@ main(int argc, char *argv[])
sop.sem_flg = 0;
\&
if (semop(semid, &sop, 1) == \-1)
- errExit("semop");
+ err(EXIT_FAILURE, "semop");
\&
exit(EXIT_SUCCESS);
}