<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 7, 2017 at 11:08 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Rui Ueyama via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> writes:<br>
<br>
> ruiu added inline comments.<br>
><br>
><br>
> ================<br>
> Comment at: ELF/Filesystem.cpp:19<br>
>  #include "llvm/Support/FileSystem.h"<br>
> +#include <unistd.h><br>
><br>
> ----------------<br>
> Does all system have unistd.h?<br>
<br>
</span>Looks like I have to check defined(HAVE_UNISTD_H). I will add that.<br>
<span class=""><br>
><br>
><br>
> ================<br>
> Comment at: ELF/Filesystem.cpp:54<br>
><br>
> -  // Remove TempPath in background.<br>
> -  runBackground([=] { ::remove(TempPath.str().str().<wbr>c_str()); });<br>
> +  sys::fs::remove(Path);<br>
> +<br>
> ----------------<br>
> Is this safe on Windows? On Windows, you can't remove opened files.<br>
<br>
</span>It depends on how they are opened. We use FILE_SHARE_DELETE in<br>
openFileForRead, so it should work.<br>
<br>
But in fact, remove being slow is a unix only problem, so I guess the<br>
best thing to do is to return early on windows. I will add that too.<br></blockquote><div><br></div><div>Makes sense.</div><div><br></div><div>I believe that it is only a Windows thing that the entire process dies with some error condition when the main thread exits while other threads are running. So, we might be able to remove runInBackground and just detach a thread that we create for calling close(2).</div></div></div></div>