From c@@rdi@g@bor @ending from gm@il@com  Fri Aug 31 15:48:44 2018
From: c@@rdi@g@bor @ending from gm@il@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Fri, 31 Aug 2018 15:48:44 +0200
Subject: [Rd] Detecting whether a process exists or not by its PID?
In-Reply-To: <cf3fb3b9-8523-c8c7-700d-bd2a75e5cbd8@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>
Message-ID: <CABtg=Kk6iXKtzuc9F558L8_PmP6r9iPDkynHEmERpRKHA+f8ig@mail.gmail.com>

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.

Gabor

[...]



[Rd] Detecting whether a process exists or not by its PID?
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=