473,661 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

register_shutdo wn_function Problems

I want to ensure that I'm releasing a lock on a file after _all_ objects
have been destroyed. What I'm trying to do is use
register_shutdo wn_function to call a function that releases the lock on
the file then closes it. Testing is showing that the registered
function is being called before all objects are destroyed. Is this
expected behaviour? Is there a way to get the desired functionality?
This is a standalone shell script/applicaton that isn't being run via a
web browser. Using PHP 5.0.1 on Linux 2.6 kernel.

- Derek
Jul 17 '05 #1
3 1771
"Derek Battams" <de***@stopspam .battams.ca> wrote in message
news:HX******** **********@hydr a.nntpserver.co m...
I want to ensure that I'm releasing a lock on a file after _all_ objects
have been destroyed. What I'm trying to do is use
register_shutdo wn_function to call a function that releases the lock on
the file then closes it. Testing is showing that the registered
function is being called before all objects are destroyed. Is this
expected behaviour? Is there a way to get the desired functionality?
This is a standalone shell script/applicaton that isn't being run via a
web browser. Using PHP 5.0.1 on Linux 2.6 kernel.

- Derek


Locks are automatically removed when the script terminates, just as open
files are automatically closed.
Jul 17 '05 #2
Chung Leong wrote:
"Derek Battams" <de***@stopspam .battams.ca> wrote in message
news:HX******** **********@hydr a.nntpserver.co m...
I want to ensure that I'm releasing a lock on a file after _all_ objects
have been destroyed. What I'm trying to do is use
register_shut down_function to call a function that releases the lock on
the file then closes it. Testing is showing that the registered
function is being called before all objects are destroyed. Is this
expected behaviour? Is there a way to get the desired functionality?
This is a standalone shell script/applicaton that isn't being run via a
web browser. Using PHP 5.0.1 on Linux 2.6 kernel.

- Derek

Locks are automatically removed when the script terminates, just as open
files are automatically closed.


True, but then I have to rely on PHP cleaning up resources in exactly
the same order each and every time. I went looking through the PHP docs
to see if the order of resource cleanup is guaranteed, but I don't see
any documentation saying that it is. My testing does show that in PHP
5.0.1 on Linux that opened files are closed after object destruction,
but is this always going to be the case? Also, I don't like leaving
resource cleanup to be implicitly done by the PHP engine, unless I can
find docs that promise the order in which it will be done.

- Derek
Jul 17 '05 #3
"Derek Battams" <de***@stopspam .battams.ca> wrote in message
news:%p******** ***********@hyd ra.nntpserver.c om...
True, but then I have to rely on PHP cleaning up resources in exactly
the same order each and every time. I went looking through the PHP docs
to see if the order of resource cleanup is guaranteed, but I don't see
any documentation saying that it is. My testing does show that in PHP
5.0.1 on Linux that opened files are closed after object destruction,
but is this always going to be the case? Also, I don't like leaving
resource cleanup to be implicitly done by the PHP engine, unless I can
find docs that promise the order in which it will be done.


"Resources are a special kind of data type in PHP. The term resources
doesn't really refer to any special kind of data, but to an abstraction
method for maintaining any kind of information. Resources are kept in a
special resource list within Zend. Each entry in the list has a
correspondendin g type definition that denotes the kind of resource to which
it refers. Zend then internally manages all references to this resource.
Access to a resource is never possible directly - only via a provided API.
As soon as all references to a specific resource are lost, a corresponding
shutdown function is called."

Hence the answer is yes, resources will be destroyed in the correct order.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2117
by: | last post by:
Hi all ! I am using register_shutdown_function. It behaves something strange. register_shutdown_function("f1"); register_shutdown_function("f2"); they fire in sequence f1
2
1915
by: Joshua Beall | last post by:
Hi All, I use register_shutdown_function to register a function that then gets run when the script finishes executing. It worked great before, but sometime last week on my development server all my sites started going very slowly. It is still running fine on the production server (thankfully). Nothing was changed. In fact, I was out of town that week, and the dev server was powered off.
1
2422
by: yawnmoth | last post by:
Say I have the following PHP script: <? register_shutdown_function('test'); ob_start(); echo "part2"; function test() { $output = ob_get_contents();
14
2316
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are going to use .Net......I highly recommend signing up for the free KBAlertz newsletter at http://www.kbalertz.com/default.aspx. Looking at all of the errors and quirks sometimes makes me wonder if this thing is really ready for prime time.
1
3039
by: 3f | last post by:
Hello; We have made a web application that people can download from our web site and installed on: Windows XP Windows 2000 Professional Windows 2003 Server Windows 2000 Server
2
3608
by: alex bazan | last post by:
I came across this function as i got a problem with very long-running scripts which use transactions... in the php manual i do not see clearly stated if the function defined will be executed if a timeout is reached. It states: "Registers the function named by function to be executed when script processing is complete."
5
8792
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) - DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL But this doesn't: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
10
2402
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
0
2238
by: Sergistm | last post by:
Hello World, :D I have a problem that it is making me crazy, I hope you can help me. I'm trying to execute a .exe file with the Procces.Start, and there is no problem when the file is on my computer, the problem comes when the file is in a network drive. The most amazing thing is that in one computer I can execute my .Net program without problems independently if the file is
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8855
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.