2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2015, Joyent, Inc.
17 * Verify that using MC_INHERIT_ZERO works just fine when applied to an entire
18 * region that is mlocked.
21 #include <sys/types.h>
38 size_t mapsz
= sysconf(_SC_PAGESIZE
) * 2;
40 buf
= mmap(NULL
, mapsz
, PROT_READ
| PROT_WRITE
,
41 MAP_PRIVATE
| MAP_ANON
, -1, 0);
42 assert(buf
!= MAP_FAILED
);
43 memset(buf
, 'a', mapsz
);
45 ret
= mlock(buf
, mapsz
);
48 ret
= memcntl(buf
, mapsz
, MC_INHERIT_ZERO
, 0, 0, 0);
53 for (i
= 0, ubuf
= buf
; i
< mapsz
; i
++)
60 ret
= waitid(P_PID
, child
, &info
, WEXITED
);
61 } while (ret
== -1 && errno
== EINTR
);
63 assert(info
.si_pid
== child
);
64 assert(info
.si_status
== 0);
66 for (i
= 0, ubuf
= buf
; i
< mapsz
; i
++)
67 assert(ubuf
[i
] == 'a');