Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!ora!jerry From: jerry@ora.com (Jerry Peek) Newsgroups: comp.unix.questions Subject: Re: suspend process question Summary: write pid to stdout when background program starts Message-ID: <1991Feb6.163917.19663@ora.com> Date: 6 Feb 91 16:39:17 GMT References: Organization: O'Reilly and Associates Inc., Cambridge, MA Lines: 22 davis@pacific.mps.ohio-state.edu (John E. Davis) writes: > I have a program running in the background ... > I would like to be able to start and stop the program at will... I > cannot do `stop %3' or whatever since the shell is not aware of the child... > What I currently do is to do `ps -aux | grep sline' (sline is the name of > the program) to get the pid, `pid', then do `kill -STOP `pid'' ... > Is there an easier way??? How can I avoid getting the pid of the program > via `ps -aux' ... A while ago, I used a program called sysline(1) that updated the status line. It had a command line option that meant "write your PID to standard output." You could grab that number in a file at startup: # start sysline program; store its PID in "$HOME/.sysline.pid": sysline -D -l -p -i > ~/.sysline.pid Then cat the file when you needed to send a signal. I think I used an alias: alias usysline 'blah blah; kill -ALRM `cat ~/.sysline.pid`' I also had another setup that worked on multiple terminals at once. It stored the PID in an environment variable, I think. But you get the idea. --Jerry Peek, O'Reilly & Associates Inc., jerry@ora.com