From owner-freebsd-questions Tue May 16 2:56:12 2000 Delivered-To: freebsd-questions@freebsd.org Received: from jmcl.gamesnow.ie (sega1.quay.ie [192.122.220.71]) by hub.freebsd.org (Postfix) with ESMTP id 7EE4C37B875 for ; Tue, 16 May 2000 02:56:08 -0700 (PDT) (envelope-from mclaughj@gamesnow.ie) Received: from jmcl.gamesnow.ie (localhost [127.0.0.1]) by jmcl.gamesnow.ie (8.9.3/8.9.3) with ESMTP id KAA53124; Tue, 16 May 2000 10:55:57 +0100 (IST) Message-Id: <200005160955.KAA53124@jmcl.gamesnow.ie> From: "John McLaughlin" To: Alex Boisvert Cc: questions@freebsd.org Subject: Re: PID of a forked process Reply-To: jmcl@gamesnow.ie Date: Tue, 16 May 2000 10:55:57 +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I've also used `jobs' under /bin/sh to do this as follows: #!/bin/sh some_command & echo " some_command run " job_pids `jobs` echo ${job_pids} | awk -- '{ print $2; }' > /tmp/some_command.pid kill -9 `cat /tmp/some_command.pid Or I guess you could replace the last two lines with: pid=`echo ${job_pids} | awk -- '{ print $2; }'` kill -9 $pid John You wrote: > Hello, > > I have a basic BASH-related question. How does one obtain the PID of a > forked process in bash? > > Here's what I'd like to do: > > #!/usr/local/bin/bash > while test 1 > do > PID = some_long_process & > sleep 60 > kill -9 PID > done > > I'm going to use this script in a test framework where I need to test an > application for recoverability. So I want to start the application, > wait for a given amount of time and then kill this application and > repeat. > > So how to I obtain the PID of a process which is forked? I've tried %% > but it didn't work. > > regards, > alex. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message