[Thread Prev][Thread Next][Index]

Re: process ID, collisions

Inspired by a suggestion from Joe Sirott, here's a platform-independent
way to get the process identification (PID) of Ferret.  One simply needs
to obtain the PARENT process identification (PPID) of the shell launched
by the SPAWN command.  So create a Perl script "ppid":

print getppid . "\n";

and place it in a location accessible to the Ferret SPAWN command (e.g. in
your PATH).  Then access the PID in Ferret v5.4x using

yes? let pid = {spawn:"ppid"}

If your system doesn't have Perl, see Joe's C program "ppid.c" below;
you'll need to compile it separately for each platform on which you run




Date: Mon, 19 Aug 2002 16:45:38 -0700
From: Joe Sirott <sirott@pmel.noaa.gov>
Subject: Re: process ID, collisions

If your shell doesn't support a method for returning the parent process
id, and you don't want to hassle with external functions, it's trivial to
write a program to return it. I've included it below. Compile it with:

    gcc -o ppid ppid.c

and call it from Ferret as:

    sp ppid

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

int main() {

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement