[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: =?iso-8859-1?Q?variable=3DStrart=5FProgramPID =3F=3F?=



On Wed, Nov 24, 2004 at 04:18:13PM +0100, pir aa wrote:
> I wrote a bash script from which I call one c-program, that is mainly a loop.
> But in the script I would like to be able to just kill the loop. So I thought,
> that there must be a way how to get the PID of a program when starting it
> (then save it in a variable and later use it to call kill). Is there?

not sure exactly what you want here, but here an example which might help:

  find / > out &
  pid=$!
  sleep 4; kill $pid

this will find as many files as it can in about ~ 4 seconds,
then kill the find process.

The bash "info" doc is helpful, I always forget which funny variable is which,
you can type:

  info bash var

to list all the variables, this one $! is one of the "special parameters" at
the top.

You may need to install the "bash-doc" package first.

hope this helps,

Sam



Reply to: