Re: Waiting for a process to die
2009/5/31 Kelly Jones kelly.terry.jo...@gmail.com: How do I wait for a specific process to die? I want to do something like: waitpid 1234(echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) I'm sure this is trivial, but I can't find a way to do it. I wrote a Perl script that checks every second if /proc/pid exists, but that only works if /proc is mounted + I'm now on VMs which can't easily mount /proc -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. [ `ps ax |grep pid | wc -l ` = 1 ] (echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) Chris -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in a mailing list? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Waiting for a process to die
How do I wait for a specific process to die? I want to do something like: waitpid 1234(echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) if i understand you correctly: your_program parameters bg_process_number=$! ...something else... wait $bg_process_number echo done! ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Waiting for a process to die
2009/5/31 Wojciech Puchar woj...@wojtek.tensor.gdynia.pl: How do I wait for a specific process to die? I want to do something like: waitpid 1234(echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) if i understand you correctly: your_program parameters bg_process_number=$! ...something else... wait $bg_process_number echo done! Er, yeah, actually a much better idea than mine. Ignore my previous suggestion :) Chris -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in a mailing list? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Waiting for a process to die
Chris Rees wrote: [ `ps ax |grep pid | wc -l ` = 1 ] (echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) Not always going to work. For example, [ste...@scs:~]% ps ax | grep init 1 ?Ss 0:39 init [2] 13421 pts/1R+ 0:00 grep init Also if you use its pid, 1, you get a whole bunch of uninteresting processes as you're grepping for 1 ;) [ste...@scs:~]% ps ax | grep 1 | wc -l 94 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Waiting for a process to die
On Sun, May 31, 2009 at 12:42:37PM -0700, Steven Schlansker wrote: Chris Rees wrote: [ `ps ax |grep pid | wc -l ` = 1 ] (echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) Not always going to work. For example, [ste...@scs:~]% ps ax | grep init 1 ?Ss 0:39 init [2] 13421 pts/1R+ 0:00 grep init This is why you should use pgrep(1) to find a PID (and kill it) rather than directly grepping a ps output like the previous poster did. Also if you use its pid, 1, you get a whole bunch of uninteresting processes as you're grepping for 1 ;) [ste...@scs:~]% ps ax | grep 1 | wc -l 94 Wojcech nailed the approach the OP should be using. Regards, -- Frank Contact info: http://www.shute.org.uk/misc/contact.html ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: Waiting for a process to die
Frank Shute wrote: On Sun, May 31, 2009 at 12:42:37PM -0700, Steven Schlansker wrote: Chris Rees wrote: [ `ps ax |grep pid | wc -l ` = 1 ] (echo done! | Mail -s PROC DONE kelly.terry.jo...@gmail.com) Not always going to work. For example, [ste...@scs:~]% ps ax | grep init 1 ?Ss 0:39 init [2] 13421 pts/1R+ 0:00 grep init This is why you should use pgrep(1) to find a PID (and kill it) rather than directly grepping a ps output like the previous poster did. Yes, pgrep is the tool. If you already know the pid, you can use good old ps: ps 1 echo init runs ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org