From luke-tier@ey m@ili@g off uiow@@edu  Fri Aug 31 16:05:06 2018
From: luke-tier@ey m@ili@g off uiow@@edu (luke-tier@ey m@ili@g off uiow@@edu)
Date: Fri, 31 Aug 2018 09:05:06 -0500 (CDT)
Subject: [Rd] Detecting whether a process exists or not by its PID?
In-Reply-To: <CABtg=Kk6iXKtzuc9F558L8_PmP6r9iPDkynHEmERpRKHA+f8ig@mail.gmail.com>
References: <CAFDcVCS85ZWsfOwEn4-3Sev+eykSjkeNwxWq_h1ie+_dkt0B5g@mail.gmail.com>
 <1ef168ae-9889-de7e-15f2-631f755fa4aa@gmail.com>
 <CABtg=KkpUWebM8o9uVeMuYAfjcMZ17ipQ-dneOfYk4enGgnFTQ@mail.gmail.com>
 <cf3fb3b9-8523-c8c7-700d-bd2a75e5cbd8@gmail.com>
 <CABtg=Kk6iXKtzuc9F558L8_PmP6r9iPDkynHEmERpRKHA+f8ig@mail.gmail.com>
Message-ID: <alpine.DEB.2.21.1808310904090.2971@luke-Latitude-7480>

On Fri, 31 Aug 2018, G?bor Cs?rdi wrote:

> On Fri, Aug 31, 2018 at 3:35 PM Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>>
>> On 08/31/2018 03:13 PM, G?bor Cs?rdi wrote:
>>> On Fri, Aug 31, 2018 at 2:51 PM Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>>> [...]
>>>> kill(sig=0) is specified by POSIX but indeed as you say there is a race
>>>> condition due to PID-reuse.  In principle, detecting that a worker
>>>> process is still alive cannot be done correctly outside base R.
>>> I am not sure why you think so.
>> To avoid the race with PID re-use one needs access to signal handling,
>> to blocking signals, to handling sigchld. system/system2 and
>> mcparallel/mccollect in base R use these features and the interaction is
>> still safe given the specific use in system/system2 and
>> mcparallel/mccollect, yet would have to be re-visited if either of the
>> two uses change. These features cannot be safely used outside of base R
>> in contributed packages.
>
> Yes, _in theory_ this is right, and of course this only works for
> child processes.
>
> _In practice_, you do not need signal handling. The startup time stamp
> method is
> completely fine, because it is practically impossible to have two
> processes with the
> same pid and the same (high precision) startup time. This method also
> works for any
> process (not just child processes), so for PSOCK clusters as well.

PSOCK workers may not be running on the same host as the master process.

Best,

luke

>
> Gabor
>
> [...]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu


[Rd] Detecting whether a process exists or not by its PID?
luke-tier@ey m@ili@g off uiow@@edu