<p dir="auto">We don't currently expose any way of getting the PID of a child process. Arguably, this is a system-level detail that we may not want people to program to, but it should be possible to get. Currently, on a 64-bit system you can do this:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function pid(proc::Base.Process)
    proc.handle != C_NULL || error(&quot;process not running&quot;)
    int(unsafe_load(convert(Ptr{Uint32}, proc.handle + 72)))
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">pid</span>(proc<span class="pl-k">::</span><span class="pl-c1">Base.Process</span>)
    proc<span class="pl-k">.</span>handle <span class="pl-k">!=</span> <span class="pl-c1">C_NULL</span> <span class="pl-k">||</span> <span class="pl-c1">error</span>(<span class="pl-s"><span class="pl-pds">"</span>process not running<span class="pl-pds">"</span></span>)
    <span class="pl-c1">int</span>(<span class="pl-c1">unsafe_load</span>(<span class="pl-c1">convert</span>(Ptr{Uint32}, proc<span class="pl-k">.</span>handle <span class="pl-k">+</span> <span class="pl-c1">72</span>)))
<span class="pl-k">end</span></pre></div>
<p dir="auto">Obviously not ideal. This also errors if the process has already finished when you call it, which can be unpredictable. What's a good API to this? Should we fold <code class="notranslate">getpid</code> into it as a zero-argument version?</p>
<p dir="auto">Right now I don't see an easy way to obtain the process id of something I've stared through <code class="notranslate">spawn</code>, <code class="notranslate">readsfrom</code>, etc. There does exist a <code class="notranslate">getpid()</code>, I think it should be extended.</p>