[PATCH 3/3] tests: add semop.test
Dmitry V. Levin
ldv at altlinux.org
Mon Apr 18 02:17:51 UTC 2016
On Tue, Apr 12, 2016 at 02:57:47PM +0800, Fei Jie wrote:
[...]
> --- /dev/null
> +++ b/tests/semop.c
> @@ -0,0 +1,45 @@
> +#include "tests.h"
> +#include <sys/types.h>
> +#include <sys/ipc.h>
> +#include <sys/sem.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +
> +union semun
> +{
> + int val;
> + struct semid_ds *buf;
> + unsigned short *array;
> + struct seminfo *__buf;
> +};
> +
> +int
> +main(void)
> +{
> + int sem_id = semget(IPC_PRIVATE, 1, 0600);
> + if (sem_id <0)
> + perror_msg_and_fail("semget");
There are kernels built without CONFIG_SYSVIPC enabled,
so this error shouldn't be treated as fatal.
> + union semun sem_union;
> + sem_union.val = 0;
> + if (semctl(sem_id, 0, SETVAL, sem_union) == -1)
> + perror_msg_and_fail("semctl");
All resources allocated by semget must be explicitly released,
see e.g. tests/ipc_sem.c
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160418/79e68410/attachment.bin>
More information about the Strace-devel
mailing list