[Rd] Detecting whether a process exists or not by its PID?

luke-tier@ey m@ili@g off uiow@@edu luke-tier@ey m@ili@g off uiow@@edu
Fri Aug 31 16:05:06 CEST 2018


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

> On Fri, Aug 31, 2018 at 3:35 PM Tomas Kalibera <tomas.kalibera using 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 using 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 using 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 using uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu


More information about the R-devel mailing list