[HPADM] RE: get process pid at launch time [SUMMARY]

From: HAUTECOEUR Bruno (HAUTECOB@ESSILOR.fr)
Date: Tue Sep 24 2002 - 08:43:54 EDT


hi admins,

here is the summary of the about 20 answer to my question:

1. from David Lodge:

Easy enough... The PID of the last process to be run in the background is
stored within ${!!}; so:

   /opt/daemon/bin/daemond &
   print ${!!} >/var/run/daemond.pid

2. Form Richard Goodwin:

 the korn shell variable for the pid is '$$'

examples:

echo 'the PID for this process is: ' $$
echo bdf > /tmp/bdf.out.$$

3. from Allan Marillier:

        echo $$ in a Posix / korn shell, and also perl I think. I'm not sure
about C shell

4. from Cyrille Maucci:

process.sh &
echo $!

5. from Santosh Nair :

Not sure if this helps, but if you kick the process off in the
background, it gives you the process id.

6. from Anad Hotchandani:

With $$ you will be able to capture the pid of the process.

7. Andy Cranston:

In Bourne and Korn shells try this:

  sleep 180 &
  echo $!
  ps -ef | grep 'sleep 180'

In the Korn shell the wait command is handy as in:

  (sleep 30 ; echo 30 completed) &
  (sleep 20 ; echo 20 completed) &
  (sleep 10 ; echo 10 completed) &
  wait

8. from Franck Bonnet:

#include <unistd.h>

main()

{int pid;
    pid = (getpid ());
    printf ( "%d\n", pid );
}

Rgds

________________
Bruno HAUTECOEUR
Architecte système Unix
DSI / Architecture Technique - Essilor International
Tel: 33 (0)1 48 98 73 20 / Fax: 33(0)1 49 56 20 56
mail: hautecob@essilor.fr

-----Message d'origine-----
De: HAUTECOEUR Bruno [mailto:HAUTECOB@ESSILOR.fr]
Date: lundi 23 septembre 2002 18:24
À: 'hpadm'
Objet: [HPADM] get process pid at launch time

Hi admins,

i want to get the pid of a process at its launch time. How would you do this
?

rgds,

________________
Bruno HAUTECOEUR
Architecte système Unix
DSI / Architecture Technique - Essilor International
Tel: 33 (0)1 48 98 73 20 / Fax: 33(0)1 49 56 20 56
mail: hautecob@essilor.fr

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner:
owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse
only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse &
search)
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:20 EDT