mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 02:12:50 +02:00
+ workaround for newer wasmtime versions that don't report the fd type of
stdin/stdout/stderr. Always assume handles 0..2 are a device, so that standard input and output are flushed. git-svn-id: trunk@49541 -
This commit is contained in:
parent
827f543289
commit
720068360e
@ -58,8 +58,19 @@ end;
|
|||||||
|
|
||||||
function Do_IsDevice(Handle:THandle):boolean;
|
function Do_IsDevice(Handle:THandle):boolean;
|
||||||
var
|
var
|
||||||
|
res: __wasi_errno_t;
|
||||||
ourfdstat: __wasi_fdstat_t;
|
ourfdstat: __wasi_fdstat_t;
|
||||||
begin
|
begin
|
||||||
__wasi_fd_fdstat_get(Handle,@ourfdstat);
|
res:=__wasi_fd_fdstat_get(Handle,@ourfdstat);
|
||||||
Do_IsDevice:=ourfdstat.fs_filetype in [__WASI_FILETYPE_BLOCK_DEVICE,__WASI_FILETYPE_CHARACTER_DEVICE];
|
if res=__WASI_ERRNO_SUCCESS then
|
||||||
|
begin
|
||||||
|
if ourfdstat.fs_filetype=__WASI_FILETYPE_UNKNOWN then
|
||||||
|
{ wasmtime 0.24.0 and later versions return __WASI_FILETYPE_UNKNOWN for stdin/stdout/stderr }
|
||||||
|
Do_IsDevice:=Handle<=2
|
||||||
|
else
|
||||||
|
Do_IsDevice:=ourfdstat.fs_filetype in [__WASI_FILETYPE_BLOCK_DEVICE,__WASI_FILETYPE_CHARACTER_DEVICE]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{ in case of error (e.g. access denied), assume device for stdin/stdout/stderr }
|
||||||
|
Do_IsDevice:=Handle<=2;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user