6 * shmat(2) shmget(2) shmdt(2)
9 * Create and attach a shared memory segment, write to it
10 * and then detach the shared memroy twice, the second one will FAIL.
15 #include <sys/types.h>
18 #include <sys/utsname.h>
25 char *TCID
="shmt01"; /* Test program identifier. */
26 int TST_TOTAL
=4; /* Total number of test cases. */
27 extern int Tst_count
; /* Test Case counter for tst_* routines */
44 key
= (key_t
)getpid() ;
46 /*----------------------------------------------------------------*/
49 if ((shmid
= shmget(key
, 16*K_1
, IPC_CREAT
|0666)) < 0 ) {
51 tst_resm(TFAIL
, "shmget Failed: shmid = %d, errno = %d\n",
56 tst_resm(TPASS
, "shmget") ;
58 /*----------------------------------------------------------------*/
61 /* are we doing with ia64 or arm_arch_4t arch */
62 #if defined (__ia64__) || defined (__ARM_ARCH_4T__)
63 cp
= (char *) shmat(shmid
, (void *)NULL
, 0);
65 cp
= (char *) shmat(shmid
, (void *)0x80000, 0);
67 if (cp
== (char *)-1) {
69 tst_resm(TFAIL
, "shmat Failed: shmid = %d, errno = %d\n",
78 tst_resm(TPASS
, "shmat") ;
80 /*----------------------------------------------------------------*/
85 tst_resm(TFAIL
, "shmdt Failed: shmid = %d, errno = %d\n",
91 tst_resm(TPASS
, "shmdt first time.");
96 tst_resm(TFAIL
, "shmdt Failed: shmid = %d, errno = %d\n",
104 tst_resm(TPASS
, "shmdt second time.");
106 /*------------------------------------------------------------------*/
110 /*-------------------- THIS LINE IS NOT REACHED -------------------*/
117 if (shmctl(shmid
, IPC_RMID
, NULL
) == -1) {
120 "shmctl Failed to remove: shmid = %d, errno = %d\n",