[R] reading PID
B.Rowlingson@lancaster.ac.uk
B.Rowlingson at lancaster.ac.uk
Wed May 23 19:36:30 CEST 2001
Prof Brian D Ripley wrote:
> Let me point out that all of the below is at least as complicated as the
> above.
>
Okay, but:
pid <- system("echo $PPID",intern=T)
isn't. Relies on bash though.
> ??? R's tempfile can produce perfectly meaningful names.
> tempfile("job-output.")
[1] "/tmp/job-output.R10e1S79e2a9e3"
not terrifically meaningful. The application I had in mind (and I dont
think we know what the original poster's application was!) was running
several R jobs in the background producing several output files. You
could go to the effort of generating sequence numbers for each job and
encoding that in the tempfile() name, or you could get the PID and throw
that into tempfile(). Then if you decide from looking at the output
files
that one of the jobs need killing, you get the PID for free from the
file
name. Less chance of killing off that 10 million iteration MCMC that's
been
running all month...
> tempfile(paste("job.pid-",pid,"-.",sep=''))
[1] "/tmp/job.pid-4321-.R10e1S5bd062c2"
Other uses for a process to get its pid include writing it to a
pid-file,
such as that written by the apache web server, so a user can get the pid
without recourse to ps, for the purpose of sending signals to the
process.
Not sure if R lets you install a signal handler though!
Barry
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
mailing list