[R] reading PID
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Wed May 23 19:07:18 CEST 2001
On Wed, 23 May 2001 B.Rowlingson at lancaster.ac.uk wrote:
> Prof Brian Ripley wrote:
> > That's an OS-specific question, isn't it? Let me guess, Linux. There is
> > no specific way to get the pid within an R process (what could you do
> > with it?), but you can trivially dyn.load some code to tell you via a call
> > to getpid.
Let me point out that all of the below is at least as complicated as the
> On most modern Linux machines you could read in /proc/self/status and
> get the
> 'Pid:' entry. Lots of other useful stuff in there too. I haven't quite
> out how to read in the various bits neatly because of all the tab
> floating around.
> And a warning - /proc/ stuff is really meant for human eyes and not for
> to parse and obtain info from. That's what system calls are for. The
> /proc format
> is liable to change.
> Or you can get it by using system() to run a command and then the $PPID
> var to get the parent pid:
> pid <- system("echo $PPID",intern=T)
> > Of course adding a Sys.getpid() function would be easy, but what use would
> > it be?
> Several running R processes could write their output to unique files
> by pid perhaps? Would be more meaningful names than the output of
??? R's tempfile can produce perfectly meaningful names.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help