Skip to content

Help with OS X (BSD) ps command

4 messages · Jeffrey J. Hallman, Brian Ripley, Paul Roebuck +1 more

#
My fame package has a function that checks to see if a FAME SERVER process is
already running.  On Linux, I can do this in one of two ways:

  pid <- Sys.getpid()
  user <- Sys.info()["user"]

  cmd <- paste("pgrep -fU", user, "-P", pid, "'FAME SERVER'")
  fameRunning <- as.logical(length(system(cmd, intern = T)))

or I can use

  cmd <- paste("ps -ef | grep", user, "| grep", pid,
                 "| grep -v grep | grep -c 'FAME SERVER'")
  fameRunning <- as.logical(as.numeric(system(cmd, intern = T)))

Mac OS X does not have pgrep, and being a BSD derivative, takes different
arguments for the 'ps' command.  I don't have access to a BSD machine. Can
someone who does tell me the correct invocation of 'ps' to see if 'user' is
running a 'FAME SERVER' process with the R process as its parent process?

Please don't tell me how to get pgrep for OS X, as my objective here is to
stop the CRAN test machine from complaining about my invalid ps command.

While FAME is not officially supported on OS X, I am told that it can be made
to work there.  Had I not heard this, of course, I could just answer FALSE for
OS X and be done with it.
#
Most systems do not have pgrep: it is not POSIX.  From Linux:

STANDARDS
        pkill and pgrep were introduced in Sun's Solaris 7.  This implementation is fully
        compatible.


The man pages of Darwin and many other systems are online, and linked from
developer.r-project.org.  You could do what the R developers do, and look 
at them.

However, you seem not to have looked on your own system, as my Linux 'ps' 
man page tells me the BSD syntax, and I can test it on Linux's 'ps'.  I 
guess you want 'ps ux'.
On Fri, 2 Feb 2007, Jeffrey J. Hallman wrote:

            

  
    
4 days later
#
On Fri, 2 Feb 2007, Jeffrey J. Hallman wrote:

            
<<untested>>
cmd <- paste("ps -o user,ppid,command", "| ",
             "grep", user, "| ",
             "grep", pid, "| "
             "grep -c '[F]AME SERVER'")

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)
#
Hi R gurus,

If I want to bring back the old La.svd in R-2.3.0, which C files I need to bring back? The current La.svd() runs much faster, but not robust enough. It failed on some datasets. I would like to bring back the old one even it's slower.

Thank you very much for any hint.

Lei