xref: /illumos-gate/usr/src/test/os-tests/tests/i386/badseg.sh (revision 125965389c591835d37b560971900f263cc8f988)
1#!/bin/bash
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12# Copyright 2019 Joyent, Inc.
13#
14
15#
16# badseg intentionally core-dumps. It does a setrlimit(), but we need to
17# prevent global core dumps too: we'll do this by blocking the path for
18# badseg_exec, but let other processes core dump still just in case.
19#
20
21set -e
22set -x
23
24old_enabled=$(/usr/bin/svcprop -p config_params/global_enabled coreadm)
25old_pattern=$(/usr/bin/svcprop -p config_params/global_pattern coreadm)
26old_log=$(/usr/bin/svcprop -p config_params/global_log_enabled coreadm)
27
28mkfile 1m /var/cores/badseg_exec
29coreadm -e global -d log -g /var/cores/%f/%p
30# let it settle
31sleep 3
32
33$(dirname $0)/badseg_exec || true
34
35coreadm -g "$old_pattern"
36
37if [[ "$old_enabled" = "true" ]]; then
38       coreadm -e global
39fi
40
41if [[ "$old_log" = "true" ]]; then
42       coreadm -e log
43fi
44
45rm -f /var/cores/badseg_exec
46