Q: Emacs Gdb: attach to a process on start I'm wondering if a kind elisp expert can write this gdb-pounce fn, which
 will make emacs wait for a process to start, get it's pid, and tell the running
 gdb to attach to it. The command should display "Waiting for 'process' to start..."
 and pressing any key should quit the function.
Getting the pid is one of the easier part:
;; The command which will get the PID   
(setq cmd ( format "ps -u %s -o pid,fname | awk '{ if ( \"%s\" == $2 ) print($1)}"
     (user-login-name)
     binary))
(set maybe_pid (shell-command-to-string cmd) )

The place, where elisp expert is needed, is how to call this every 1 second, or till the
user presses a key to exit. 
Thanks in advance.
UPDATE:
  The script is here: https://bitbucket.org/vrdhn/gdb-pounce/raw/master/gdb-pounce.el

A: You could do something like this:
(let ((done nil))
  (while (and (not done) (not (input-pending-p)))
    (if (> (random 10) 7)
        (setq done t)
      (message "Waiting...")
      (sleep-for 1))))

I put in the random check here just as an example; that's where you'd put the check for the process.  The key parts are input-pending-p and sleep-for.
