[R] reading PID
B.Rowlingson at lancaster.ac.uk
Wed May 23 15:44:52 CEST 2001
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.
On most modern Linux machines you could read in /proc/self/status and
'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
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
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-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