xref: /freebsd/contrib/pjdfstest/tests/open/20.t (revision 41059135ce931c0f1014a999ffabc6bc470ce856)
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/open/20.t 211352 2010-08-15 21:24:17Z pjd $
3
4desc="open returns ETXTBSY when the file is a pure procedure (shared text) file that is being executed and the open() system call requests write access"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
10
11requires_exec
12
13echo "1..4"
14
15n0=`namegen`
16
17cp -pf `which sleep` ${n0}
18./${n0} 3 &
19while ! pkill -0 -f ./${n0}; do
20	sleep 0.1
21done
22expect ETXTBSY open ${n0} O_WRONLY
23expect ETXTBSY open ${n0} O_RDWR
24expect ETXTBSY open ${n0} O_RDONLY,O_TRUNC
25pkill -9 -f ./${n0}
26expect 0 unlink ${n0}
27