From owner-freebsd-questions Wed Sep 23 10:43:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA09620 for freebsd-questions-outgoing; Wed, 23 Sep 1998 10:43:50 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from david.siemens.de (david.siemens.de [192.35.17.14]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA09600 for ; Wed, 23 Sep 1998 10:43:43 -0700 (PDT) (envelope-from andre.albsmeier@mchp.siemens.de) X-Envelope-Sender-Is: andre.albsmeier@mchp.siemens.de (at relayer david.siemens.de) Received: from mail.siemens.de (salomon.siemens.de [139.23.33.13]) by david.siemens.de (8.9.1a/8.9.1) with ESMTP id TAA01943 for ; Wed, 23 Sep 1998 19:43:35 +0200 (MET DST) Received: from curry.mchp.siemens.de (daemon@curry.mchp.siemens.de [146.180.31.23]) by mail.siemens.de (8.9.1a/8.9.1) with ESMTP id TAA01076 for ; Wed, 23 Sep 1998 19:43:35 +0200 (MET DST) Received: (from daemon@localhost) by curry.mchp.siemens.de (8.8.8/8.8.8) id TAA29819 for ; Wed, 23 Sep 1998 19:43:36 +0200 (CEST) From: Andre Albsmeier Message-Id: <199809231743.TAA03306@internal> Subject: Re: How to get the PID before a program is run? (No joke :-) In-Reply-To: <360931B1.29E98E12@dal.net> from Studded at "Sep 23, 98 10:36:49 am" To: Studded@dal.net (Studded) Date: Wed, 23 Sep 1998 19:43:33 +0200 (CEST) Cc: dnelson@emsphone.com, andre.albsmeier@mchp.siemens.de, freebsd-questions@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Dan Nelson wrote: > > > How about: > > > > #! /bin/sh > > echo $$ > /var/run/program.pid > > $$ is the pid of the shell. NoNo, I want the PID of the program I will start from the shell. It can be done with two shell scripts: No. 2 is run by No. 1 and exec's my program when No. 1 has finished doing it's stuff with the PID of No. 2. When my program finishes, No. 1 can remove the stuff it has done and exits. However, I am just writing a small C program which does this (by fork()) since this easier than havin two shell scripts talking with each other. -Andre To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message