<div dir="ltr">Hi Jay,<div><br></div><div>  I can't see that code anywhere in that file on git. What version are you using?</div><div><br></div><div>By the way, you wouldnt happen to know if we can get LTO support in the backend would you? </div><div><br></div><div>Regards Peter</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 15, 2017 at 8:20 AM, Jay K <span dir="ltr"><<a href="mailto:jayk123@hotmail.com" target="_blank">jayk123@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_-2807824095065338855divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><br>
/mnt/d/dev2/cm3-5.8.6/m3-libs/<wbr>libm3/src/os/POSIX/<wbr>ProcessPosixCommon.m3</p>
<p><br>
</p>
<p>PROCEDURE Create_ForkExec:</p>
<p>.<br>
.<br>
.<br>
    (* Turn off the interval timer (so it won't be running in child). *)</p>
<p>    nit := Utime.struct_itimerval { <br>
             it_interval := Utime.struct_timeval {0, 0}, <br>
             it_value    := Utime.struct_timeval {0, 0}}; <br>
    IF Utime.setitimer(Utime.ITIMER_<wbr>VIRTUAL, nit, oit) < 0 THEN <br>
      <* ASSERT FALSE *> <br>
    END; <br>
 . <br>
 . </p>
<p> .</p>
<p>  fork() </p>
<p> . <br>
 . </p>
<p><br>
    (* Enable scheduler. *) <br>
    Scheduler.EnableSwitching (); </p>
<p>    (* Restore previous virtual timer. *) <br>
    IF Utime.setitimer(Utime.ITIMER_<wbr>VIRTUAL, oit, nit) < 0 THEN <br>
      <* ASSERT FALSE *> <br>
    END; </p>
<p> <br>
 This code has a number of problems.  </p>
<p> - It looks thread-unsafe -- another thread could be changing the timer. </p>
<p> </p>
<p> - The comments are wrong in multiple ways.<br>
   The timer doesn't have to be turned off to not run in the child.<br>
   Timers except alarm() are not inherited by child.<br>
   It goes ahead and enables in the child anyway. Granted, after EnableSwitching,<br>
   which also enables it! </p>
<p><br>
</p>
<p> - Doesn't work on Microsoft's Windows Subsystem for Linux (WSL).</p>
<p>  You get back -1/EINVAL.</p>
<p><br>
</p>
<p> - Is probably specific to user threads?</p>
<p> </p>
<p>- Fails to put a useful message in the assert other than "FALSE"</p>
<p> </p>
<p>Proposals:</p>
<p> 1. Remove it.<br>
 2. Make it check for and ignore EINVAL, and possibly WSL, and not then enable in child.<br>
 3. Change it to get in parent and set in child if enabled. </p>
<p> 4. Move it to Thread.AtFork in user threads. Though again, not clearly needed there.</p>
<p><br>
</p>
<p> 5. Consider that fork+exec should work from C/C++ code in a process that is using Modula3.</p>
<p><br>
</p>
<p> 6. Research posix_spawn and use it more. </p>
<p> We can probably just use it and forget about any system that lacks it.</p>
<p><br>
Thoughts?</p>
<p> WSL can be detected by searching for "Microsoft" in /proc/sys/kernel/osrelease or /proc/version.</p>
<p><br>
</p>
<p> Or we can just accept -1/EINVAL here for any OS.</p><span class="HOEnZb"><font color="#888888">
<p><br>
</p>
<p><br>
</p>
<p> - Jay</p>
<p><br>
</p>
</font></span></div>
</div>

<br>______________________________<wbr>_________________<br>
M3devel mailing list<br>
<a href="mailto:M3devel@elegosoft.com">M3devel@elegosoft.com</a><br>
<a href="https://m3lists.elegosoft.com/mailman/listinfo/m3devel" rel="noreferrer" target="_blank">https://m3lists.elegosoft.com/<wbr>mailman/listinfo/m3devel</a><br>
<br></blockquote></div><br></div>