From owner-freebsd-questions Wed Sep 23 09:25:41 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA23747 for freebsd-questions-outgoing; Wed, 23 Sep 1998 09:25:41 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from pau-amma.whistle.com (s205m64.whistle.com [207.76.205.64]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA23715 for ; Wed, 23 Sep 1998 09:25:25 -0700 (PDT) (envelope-from dhw@whistle.com) Received: (from dhw@localhost) by pau-amma.whistle.com (8.8.8/8.8.7) id JAA05443; Wed, 23 Sep 1998 09:23:41 -0700 (PDT) (envelope-from dhw) Date: Wed, 23 Sep 1998 09:23:41 -0700 (PDT) From: David Wolfskill Message-Id: <199809231623.JAA05443@pau-amma.whistle.com> To: andre.albsmeier@mchp.siemens.de, freebsd-questions@FreeBSD.ORG Subject: Re: How to get the PID before a program is run? (No joke :-) In-Reply-To: <199809230729.JAA12131@internal> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >From: Andre Albsmeier >Date: Wed, 23 Sep 1998 09:29:47 +0200 (CEST) >I have a rather curious problem here: >I want to start a program but I need its PID before >it is run. One way would be to load the program and >send a -STOP signal very quickly. Then I have got the >PID, can do some things and send a -CONT signal when >finished. That does not meet the stated requirement of determining the PID *before* it's run. Indeed, I don't know of a way to accomplish the stated requirement. >This is rather ugly. On my old Atari ST there was a >function Pexec() which could be called with a special >parameter which did all things in order to run a >program but actually didn't pass control to it. >I am sure there must be an esay way to do this on >FreeBSD but I didn't find any. My preferred way >of using it would be in a shell script but every >hint is welcome. Well, when you fork(), the parent is told the child process' PID right away. You could "wrap" the real program in a shell script that immediately issues a "kill -STOP" before doing an "exec" of the real program, I suppose. david -- David Wolfskill UNIX System Administrator dhw@whistle.com voice: (650) 577-7158 pager: (650) 371-4621 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message