<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>FilePosix.m3:<br><br><br>I'm not 100% sure, but looks really bad.<br>I suspect it will close arbitrary files out from other threads.<br>Notice there is absolutely no mutual exclusion.<br>An arbitrary number of threads will run here, mostly succeeding, but not necessarily.<br><br>VAR<br> null_done := FALSE;<br> null_stat: Ustat.struct_stat;<br> null_fd: INTEGER;<br><br><br>PROCEDURE IsDevNull(READONLY statbuf: Ustat.struct_stat): BOOLEAN RAISES {} =<br> VAR result: INTEGER;<br> BEGIN<br> IF NOT null_done THEN<br> null_fd := Unix.open(M3toC.FlatTtoS("/dev/null"), Unix.O_RDONLY, Unix.Mrwrwrw);<br> IF null_fd < 0 THEN<br> null_done := TRUE;<br> RETURN FALSE<br> ELSE<br> result := Ustat.fstat(null_fd, ADR(null_stat));<br> EVAL Unix.close(null_fd);<br> IF result # 0 THEN<br> null_fd := -1<br> END<br> END;<br> null_done := TRUE;<br> END;<br> RETURN null_fd >= 0 AND statbuf.st_rdev = null_stat.st_rdev<br> END IsDevNull;<br><br><br> - Jay<br> </div></body>
</html>