static or stuff like that
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?
Quoted 2 lines · Wrazlov
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.
Signature · 1 line
Glynn Clements <[email protected]>
Hi Glynn,
Quoted 9 lines · On Sun, 28 Apr 2002 22:52:39 +0100 Glynn Clements <[email protected]>…
Quoted 2 lines · Wrazlov
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
Signature · 1 line
wwp
Quoted 8 lines · wwp
Quoted 6 lines
Quoted 2 lines
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.
Quoted 1 line
(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).
Signature · 1 line
Glynn Clements <[email protected]>
Hi Glynn,
Quoted 7 lines · On Mon, 29 Apr 2002 10:48:41 +0100 Glynn Clements <[email protected]>…
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
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.
Quoted 7 lines
Quoted 1 line
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,
Signature · 1 line
wwp
Quoted 14 lines · wwp
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
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.
Quoted 7 lines
Quoted 1 line
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.
Quoted 6 lines
[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.
Signature · 1 line
Glynn Clements <[email protected]>