diff --git a/.gitattributes b/.gitattributes index 8e31940a1e..a3cd456cfc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14487,6 +14487,7 @@ tests/webtbs/tw27880.pp svneol=native#text/plain tests/webtbs/tw2789.pp svneol=native#text/plain tests/webtbs/tw2794.pp svneol=native#text/plain tests/webtbs/tw27998.pp svneol=native#text/plain +tests/webtbs/tw27998a.pp svneol=native#text/plain tests/webtbs/tw28007.pp svneol=native#text/pascal tests/webtbs/tw2803.pp svneol=native#text/plain tests/webtbs/tw2806.pp svneol=native#text/plain diff --git a/rtl/unix/sysutils.pp b/rtl/unix/sysutils.pp index 841fd084ae..04cb8b2e4e 100644 --- a/rtl/unix/sysutils.pp +++ b/rtl/unix/sysutils.pp @@ -396,10 +396,9 @@ begin fmShareCompat, fmShareExclusive: lockop:=LOCK_EX or LOCK_NB; - fmShareDenyWrite: - lockop:=LOCK_SH or LOCK_NB; + fmShareDenyWrite, fmShareDenyNone: - exit; + lockop:=LOCK_SH or LOCK_NB; else begin { fmShareDenyRead does not exit under *nix, only shared access diff --git a/tests/webtbs/tw27998a.pp b/tests/webtbs/tw27998a.pp new file mode 100644 index 0000000000..d59da2471c --- /dev/null +++ b/tests/webtbs/tw27998a.pp @@ -0,0 +1,23 @@ +program a; +{$mode delphi} +uses + SysUtils, Classes; +const + LockFile = 'lock.txt'; +var + H, H2 : TStream; +begin + try + H := TFileStream.Create(lockFile, fmCreate); + { should raise exception because of exclusive lock above } + H2 := TFileStream.create(LockFile, fmOpenRead or fmShareDenyNone); + H2.free; + H.free; + DeleteFile(LockFile); + halt(1); + except + H.free; + DeleteFile(LockFile); + end +end. +