[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: how can I make sure only one instance of gkrellm runs

On 16Oct2008 18:38, Patrick O'Callaghan <pocallaghan gmail com> wrote:
| 2) What does "kill -0" do? "man kill" doesn't mention this possibilty.

It is the standard way of probing for a process given a pid.
It does everything any other signal does except get delivered to the
process (the process never sees it).
There are three outcomes for the caller:
    the process exists
    no such process: the process does not exist
    permission denied: the process exists, but you don't own it

You're looking at the wrong man page, BTW.

"man 3p kill" says:

  The kill() function shall send a signal to a process or a group of
  processes  specified by pid. The signal to be sent is specified by sig and
  is either one from the list given in <signal.h> or 0. If sig is 0 (the null
  signal),  error  checking  is performed but no signal is actually sent. The
  null signal can be used to check the validity of pid.

"man 2 kill" says:

  If sig is 0, then no signal is sent, but error checking is  still

This behaviour dates from at least V7 UNIX (1970s) and probly earlier.

| 3) The script has an obvious race condition, (i.e. if run from several
| places simultaneously, there is a non-zero probability of starting more
| than one process). This is because running the process and creating the
| pidfile are two separate actions.

Absolutely; I may even have mentioned this when I posted the script for
this user some months ago. But for a single person running a single GUI
it may serve. There are better ways, without races, but they are a bit
more cumbersome to script and to understand.

Cameron Simpson <cs zip com au> DoD#743

It's as if all of Scottish cuisine is based on a dare.  - Saturday Night Live

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]