From rfunk Wed Sep 22 12:05:36 1999 Subject: Re: [COLUG] HUP To: colug@bopper.wcbe.org Date: Wed, 22 Sep 1999 12:05:36 -0400 (EDT) hunter wrote: >How 'bout a portible version which does not depend on the >presence of an accurate PID file (uses the 'new' ps syntax): > > kill -HUP ` ps ax | grep [i]net | awk {' print $1 '}` And here we get into the most annoying incompatibility between Unices -- different switches for ps. The switches (and lack of "-") here are for the BSD version, which Linux wisely copied, but SysV systems have a totally different set of switches. A potential solution, used by more modern daemons, is for the daemon put the pid in a file itself, so you never need to use ps. Voila, instant portability, right? Besides, I think everybody has always agreed that grepping through a ps listing is a kludge, particularly when you take into account the answer to the bonus question below. But since not every daemon always creates the pid file (particularly old ones like inetd), and the preferred location of the file varies by OS (and Linux distribution), the "right" solution becomes less portable than the unportable solution it was supposed to replace. You can't win. BTW, I'd put the single quotes outside the {} in the awk line above -- {} are special to C shells. And I agree with Jim's idea of combining the grep into the awk (though I'd single-quote the awk expression, so the $ doesn't need a backslash). >... bonus points -- explan WHY the grep expression is 'funny >looking' Since I'm here, and nobody's answered yet.... otherwise you also get the pid for the grep process. The funny-looking grep expression should also be quoted, since otherwise the shell thinks you're trying to match a file because of the [].