8000 minix/test/ipc/shmget/shmget05.c at v3.2.0 · dtytomi/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
214 lines (179 loc) · 4.96 KB

shmget05.c

File metadata and controls

214 lines (179 loc) · 4.96 KB
}
}
/*
* setup() - performs all the ONE TIME setup for this test.
*/
void
setup(void)
{
/* check for root as process owner */
check_root();
/* capture signals */
tst_sig(FORK, DEF_HANDLER, cleanup);
/* Set up the expected error numbers for -e option */
TEST_EXP_ENOS(exp_enos);
/* Pause if that option was specified */
TEST_PAUSE;
/*
* Create a temporary directory and cd into it.
* This helps to ensure that a unique msgkey is created.
* See ../lib/libipc.c for more information.
*/
tst_tmpdir();
/* get an IPC resource key */
shmkey = getipckey();
/* create a shared memory segment with read and write permissions */
if ((shm_id_1 = shmget(shmkey, SHM_SIZE,
SHM_RW | IPC_CREAT | IPC_EXCL)) == -1) {
tst_brkm(TBROK, cleanup, "Failed to create shared memory "
"segment in setup");
}
/* get the userid for a non root user */
ltp_uid = getuserid(ltp_user);
}
/*
* cleanup() - performs all the ONE TIME cleanup for this test at completion
* or premature exit.
*/
void
cleanup(void)
{
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit();
}
0