Well, your button is the one that starts the script. If you have access
to the code in the button, the button code can write the .lck file and
then decide to spawn the perl script, or ignore the click, then the perl
script can delete the .lck file, if the perl script is being
run in a separate process.
It sounds like to me that the perl script migh be part of the same
script that is running due to the button click, and exiting is
terminating both instances. In that case, simply have the second instance
spin (it knows it is the second instance because the .lck file exists)
until the .lck file is removed, and then exit, or do what I indicated
above for the button code. more than one way to clean the clock.
bug
On Tue, 28 Mar 2000, Michael D. Kirkpatrick wrote:
> One minor problem with doing it that way...
>
> If I double click on the submit button, it works. The second process is
> terminated immediately. However, the original process goes into defunct status
> and exits after it is done processing the databases. It never makes it to the
> exit routine that removes the .lock file. So the file is stuck and the process
> will not run again until it is removed. Any suggestions?
>
> Any ideas on how I can kill the previous process if I double click on the submit
> button? That would work for me... I am not sure how to check for a second
> process and capture it's pid#. Once I obtain the pid#, how do I kill that
> process in perl?
>
> Thanks in advance.
>
> Bug Hunter wrote:
>
> > If you create a lock file (perhaps in /var/lock), with the program's
> > file name, ending in .lck, you can check for that at the beginning of the
> > perl script and exit immediately if that file exists. At the end of the
> > perl script delete the file.
> >
> > You can still have a race condition if two people click on the button at
> > the same instance, but it is highly unlikely, and can be disregarded for
> > your purposes.
> >
> > bug
>