Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Determining if self is already running under WinNT/2000

by fsn (Friar)
on Feb 06, 2003 at 22:35 UTC ( #233303=note: print w/replies, xml ) Need Help??


in reply to Determining if self is already running under WinNT/2000

Does Win32 have Process IDs like in Unix? If it does, may I humbly suggest using a PID file?

If it doesn't, what does 'print "$$\n"' give you on a Win32 system?

  • Comment on Re: Determining if self is already running under WinNT/2000

Replies are listed 'Best First'.
Re: Re: Determining if self is already running under WinNT/2000
by theorbtwo (Prior) on Feb 06, 2003 at 22:50 UTC

    Win32 has PIDs as usual, though they tend to be more annoying numbers, since they're really pointers into a kernel memory structure. IOW, you can use all the standard methods for dealing with this.

    You can also use a Mutex kernel-object, which is the standard win32 way of dealing with it. See Win32::Mutex. This has the advantage of not creating files, and not having problems with the lockfiles of dead processes staying around. OTOH, it doesn't have the transparency that lockfiles/pidfiles do, and it's inherently nonportable.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Re: Determining if self is already running under WinNT/2000
by lrep (Novice) on Feb 06, 2003 at 22:49 UTC
    Yes, That will print the PID. But Let me put it another way. I am trying to put in a test in the program to stop the user from starting-up more than one instance of the program at a time. So on startup if I count more than one instance running, I can abort out. With a nice message to the user of course. I am trying to resist the idea of pipeing out to an external program like tlist.exe or some favor of ps.exe to get the process list.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://233303]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2022-12-06 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?