<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I don't know if it's relevant, but even on Windows, the behavior described here (that the process exits if the main thread exits even while other threads are running) only occurs if the main thread exits via the CRT. Exiting the main thread
 by calling ExitThread directly will leave the process running. See <a href="https://blogs.msdn.microsoft.com/oldnewthing/20100827-00/?p=13023">
https://blogs.msdn.microsoft.com/oldnewthing/20100827-00/?p=13023</a>.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">llvm-commits <llvm-commits-bounces@lists.llvm.org> on behalf of Rui Ueyama via llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Reply-To: </b>Rui Ueyama <ruiu@google.com><br>
<b>Date: </b>Tuesday, November 7, 2017 at 11:17 AM<br>
<b>To: </b>Rafael Avila de Espindola <rafael.espindola@gmail.com><br>
<b>Cc: </b>"arichardson.kde@gmail.com" <arichardson.kde@gmail.com>, "reviews+D39710+public+26765ebae200d03e@reviews.llvm.org" <reviews+D39710+public+26765ebae200d03e@reviews.llvm.org>, llvm-commits <llvm-commits@lists.llvm.org><br>
<b>Subject: </b>Re: [PATCH] D39710: Simplify unlinkAsync<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Nov 7, 2017 at 11:08 AM, Rafael Avila de Espindola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">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>
Looks like I have to check defined(HAVE_UNISTD_H). I will add that.<br>
<br>
><br>
><br>
> ================<br>
> Comment at: ELF/Filesystem.cpp:54<br>
><br>
> -  // Remove TempPath in background.<br>
> -  runBackground([=] { ::remove(TempPath.str().str().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>
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.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Makes sense.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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).<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>