On 14Sep2008 17:19, Antonio Olivares <[EMAIL PROTECTED]> wrote:
| Dear fellow Fedora users,
| 
| I have a little problem when starting KDE.  I have multiple versions of 
gkrellm running at the same time, and I configured it to "not run multiple 
instances".  When I run top, I see several gkrellm(s), how do I prevent this?
| 
| I have run this for a while and it is getting tiring
| 
| $ killall -9 gkrellm

Gah! NEVER reach for "-9" first. It is a signal of last resort.

| $ gkrellm &

The trivial way is this:

  pidfile=$HOME/.grkrellm.pid
  if [ -s "$pidfile" ] && pid=$(<"$pidfile") && kill -0 "$pid" 2>/dev/null
  then
    echo GKrellM already running, pid=$pid, not starting a new one.
  else
    gkrellm &           # start gkrellm
    echo $! >"$pidfile" # save the pid
  fi

It is slightly racy, but not on a scale you are likely to encounter in
typical use.

Frankly, "killall" is a command I try NEVER to go near. It is like
trying to break an egg by letting off a grenade.

Cheers,
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/

Careful and correct use of language is a powerful aid to straight thinking,
for putting into words precisely what we mean necessitates getting our own
minds quite clear on what we mean.      - W.I.B. Beveridge

-- 
fedora-list mailing list
[email protected]
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Reply via email to