xref: /freebsd/contrib/pjdfstest/tests/open/20.t (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/open/20.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="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"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit
11noexec && quick_exit
12
13requires_exec
14
15echo "1..4"
16
17n0=`namegen`
18
19cp -pf `which sleep` ${n0}
20./${n0} 3 &
21while ! pkill -0 -f ./${n0}; do
22	sleep 0.1
23done
24expect ETXTBSY open ${n0} O_WRONLY
25expect ETXTBSY open ${n0} O_RDWR
26expect ETXTBSY open ${n0} O_RDONLY,O_TRUNC
27pkill -9 -f ./${n0}
28expect 0 unlink ${n0}
29