Fix race when testing for ETXTBSY writing to ${n0} (process image) by making

sure the process has been started beforehand with pgrep

pkill the process afterwards to make sure it's dead when the unlink is run
(not strictly required, but I was being conservative)

MFC after: 1 week
Reviewed by: Darius O'Conner, mjohnston
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2015-04-16 03:35:47 +00:00
parent 546afaf83d
commit f95c930e67
2 changed files with 8 additions and 0 deletions

View file

@ -14,7 +14,11 @@ n0=`namegen`
cp -pf `which sleep` ${n0}
./${n0} 3 &
while ! pkill -0 -f ./${n0}; do
sleep 0.1
done
expect ETXTBSY open ${n0} O_WRONLY
expect ETXTBSY open ${n0} O_RDWR
expect ETXTBSY open ${n0} O_RDONLY,O_TRUNC
pkill -9 -f ./${n0}
expect 0 unlink ${n0}

View file

@ -14,5 +14,9 @@ n0=`namegen`
cp -pf `which sleep` ${n0}
./${n0} 3 &
while ! pkill -0 -f ./${n0}; do
sleep 0.1
done
expect ETXTBSY truncate ${n0} 123
pkill -9 -f ./${n0}
expect 0 unlink ${n0}