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 across multiple children.
21 #include <sys/types.h>
30 static int nchild
= 5;
40 size_t mapsz
= sysconf(_SC_PAGESIZE
) * 2;
42 buf
= mmap(NULL
, mapsz
, PROT_READ
| PROT_WRITE
,
43 MAP_PRIVATE
| MAP_ANON
, -1, 0);
44 assert(buf
!= MAP_FAILED
);
46 ret
= memcntl(buf
, mapsz
, MC_INHERIT_ZERO
, 0, 0, 0);
50 memset(buf
, 'a' + nchild
, mapsz
);
54 for (i
= 0, ubuf
= buf
; i
< mapsz
; i
++)
63 ret
= waitid(P_PID
, child
, &info
, WEXITED
);
64 } while (ret
== -1 && errno
== EINTR
);
66 assert(info
.si_pid
== child
);
67 assert(info
.si_status
== 0);
69 for (i
= 0, ubuf
= buf
; i
< mapsz
; i
++)
70 assert(ubuf
[i
] == 'a' + nchild
);