Package: procps
Version: 1:3.2.7-5
Severity: wishlist

Every now and then, you want to wait for some process to finish before
starting another. As long as you are in the same shell that is usually
not a problem. But when the process belongs to another session or user,
it won't work.
That's when I'd like to see a tool like
  pbusywait expensive-process && start-my-expensive-process
it could also be used like
  pbusywait daemon-i-started-earlier && notify-me-it-has-crashed
to allow for some cheap 'command line monitoring' convenience.

I'm aware that (at least without help from the process owner or pid 1)
this isn't possible without busy waiting, i.e. polling if the process
still exists. I'm also aware that there are potential race conditions
here when a new process would get the same PID assigned while the
polling process is still waiting. Still it would be really useful to me.

Here's what I'm using right now:
---
#!/bin/sh
pid=`pgrep -of [EMAIL PROTECTED]
if [ -z "$pid" ]; then
        echo "No pid found." >&2
        exit 2
fi
echo "Waiting for pid $pid."
while test -d "/proc/$pid"; do
        sleep .1
done
# Make sure it's gone...
test -d "/proc/$pid" || exit 1
exit 1
---

Note the use of -o -- I'd otherwise see two shell processes of my
busywaitpid script. Which is one of the huge benefits of using pgrep
instead of "ps | grep". So I'd love to see a pbusywait command which
knows how to handle this. For reasons of shared functionality, code and
shared parameters, it would probably make sense to integrate this with
pgrep/pkill. Probably less than 1k overhead?

--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.23-1-686

Debian Release: lenny/sid
  500 unstable        www.debian-multimedia.org 
  500 unstable        ftp.de.debian.org 
    1 experimental    ftp.de.debian.org 

--- Package information. ---
Depends            (Version) | Installed
============================-+-=============
libc6           (>= 2.6.1-1) | 2.7-5
libncurses5         (>= 5.6) | 5.6+20071215-1
lsb-base         (>= 3.0-10) | 3.1-24

best regards,
Erich Schubert
-- 
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C     (o_
 A man doesn't know what he knows until he knows what he doesn't know. //\
      Zwei Freunde müssen sich im Herzen ähneln, in allem anderen      V_/_
         können sie grundverschieden sein. --- Sully Prudhomme



Reply via email to