linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* static or stuff like that
@ 2002-04-28 16:59 Wrazlov
  2002-04-28 21:52 ` Glynn Clements
  0 siblings, 1 reply; 6+ messages in thread
From: Wrazlov @ 2002-04-28 16:59 UTC (permalink / raw)
  To: linux-c-programming

Hi there,
I want to control whether a process is already running or not, and i don't 
know how without using some kind of lock-files, wasn't there something like
static int x=0;
or stuff like that to get how many processes are running?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: static or stuff like that
  2002-04-28 16:59 static or stuff like that Wrazlov
@ 2002-04-28 21:52 ` Glynn Clements
  2002-04-29  9:09   ` wwp
  0 siblings, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2002-04-28 21:52 UTC (permalink / raw)
  To: wrazlov; +Cc: linux-c-programming


Wrazlov wrote:

> I want to control whether a process is already running or not, and i don't 
> know how without using some kind of lock-files

You can scan the files under /proc/<pid> to obtain details about which
processes are running. E.g. /proc/<pid>/exe is a symlink to the
program which process <pid> is executing.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: static or stuff like that
  2002-04-28 21:52 ` Glynn Clements
@ 2002-04-29  9:09   ` wwp
  2002-04-29  9:48     ` Glynn Clements
  0 siblings, 1 reply; 6+ messages in thread
From: wwp @ 2002-04-29  9:09 UTC (permalink / raw)
  To: linux-c-programming

Hi Glynn,


On Sun, 28 Apr 2002 22:52:39 +0100 Glynn Clements <glynn.clements@virgin.net> wrote:

> 
> Wrazlov wrote:
> 
> > I want to control whether a process is already running or not, and i don't 
> > know how without using some kind of lock-files
> 
> You can scan the files under /proc/<pid> to obtain details about which
> processes are running. E.g. /proc/<pid>/exe is a symlink to the
> program which process <pid> is executing.

Is /proc always available? (if not, how to do what Wrazlov asked?)


Regards

-- 
wwp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: static or stuff like that
  2002-04-29  9:09   ` wwp
@ 2002-04-29  9:48     ` Glynn Clements
  2002-04-30 21:26       ` wwp
  0 siblings, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2002-04-29  9:48 UTC (permalink / raw)
  To: wwp; +Cc: linux-c-programming


wwp wrote:

> > > I want to control whether a process is already running or not, and i don't 
> > > know how without using some kind of lock-files
> > 
> > You can scan the files under /proc/<pid> to obtain details about which
> > processes are running. E.g. /proc/<pid>/exe is a symlink to the
> > program which process <pid> is executing.
> 
> Is /proc always available?

It's possible that /proc isn't mounted but, if it isn't, many OS
features won't work (e.g. modprobe). Unless you're targeting a very
minimal system (e.g. embedded systems), or writing code which will run
early in the boot sequence, it's safe to assume that /proc will be
available.

> (if not, how to do what Wrazlov asked?)

Without /proc, the only way in which you could obtain information on
other processes is by examining the kernel data structures via
/dev/kmem.

BTW, /dev/kmem is the traditional mechanism for implementing "ps", but
it has a number of drawbacks (e.g. requiring root privilege, having to
modify "ps" if the format of the relevant kernel data structures
changes).

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: static or stuff like that
  2002-04-29  9:48     ` Glynn Clements
@ 2002-04-30 21:26       ` wwp
  2002-05-01  0:12         ` Glynn Clements
  0 siblings, 1 reply; 6+ messages in thread
From: wwp @ 2002-04-30 21:26 UTC (permalink / raw)
  To: Glynn Clements; +Cc: linux-c-programming

Hi Glynn,

On Mon, 29 Apr 2002 10:48:41 +0100 Glynn Clements
<glynn.clements@virgin.net> wrote:

> > > > I want to control whether a process is already running or not,
> > > > and i don't know how without using some kind of lock-files
> > > 
> > > You can scan the files under /proc/<pid> to obtain details about
> > > which processes are running. E.g. /proc/<pid>/exe is a symlink to
> > > the program which process <pid> is executing.
> > 
> > Is /proc always available?
> 
> It's possible that /proc isn't mounted but, if it isn't, many OS
> features won't work (e.g. modprobe). Unless you're targeting a very
> minimal system (e.g. embedded systems), or writing code which will run
> early in the boot sequence, it's safe to assume that /proc will be
> available.
[snip]

Thanx for your answers.
I've also seen software using unix domain socket to prohibit duplicate
launch of a program on a POSIX system.
What do you think of this method, Glynn?


Regards,

-- 
wwp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: static or stuff like that
  2002-04-30 21:26       ` wwp
@ 2002-05-01  0:12         ` Glynn Clements
  0 siblings, 0 replies; 6+ messages in thread
From: Glynn Clements @ 2002-05-01  0:12 UTC (permalink / raw)
  To: wwp; +Cc: linux-c-programming


wwp wrote:

> > > > > I want to control whether a process is already running or not,
> > > > > and i don't know how without using some kind of lock-files
> > > > 
> > > > You can scan the files under /proc/<pid> to obtain details about
> > > > which processes are running. E.g. /proc/<pid>/exe is a symlink to
> > > > the program which process <pid> is executing.
> > > 
> > > Is /proc always available?
> > 
> > It's possible that /proc isn't mounted but, if it isn't, many OS
> > features won't work (e.g. modprobe). Unless you're targeting a very
> > minimal system (e.g. embedded systems), or writing code which will run
> > early in the boot sequence, it's safe to assume that /proc will be
> > available.
> [snip]
> 
> Thanx for your answers.
> I've also seen software using unix domain socket to prohibit duplicate
> launch of a program on a POSIX system.
> What do you think of this method, Glynn?

I don't see that this is any different to using a lock file.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-05-01  0:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-28 16:59 static or stuff like that Wrazlov
2002-04-28 21:52 ` Glynn Clements
2002-04-29  9:09   ` wwp
2002-04-29  9:48     ` Glynn Clements
2002-04-30 21:26       ` wwp
2002-05-01  0:12         ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).