Re: [PHP-DEV] Bug #10744: session_start() serializes exec

2001-05-10 Thread Oleg Makarenko

 Try this in a script:
 ?php
   exec( /bin/sleep 30 /dev/null 21 /dev/null  ) ;
   echo Done !! ;
 ?
 
 Now call it from the browser several time (Reload button). If you type a ps ax 
command you will see several sleep 30 processes. Wait all the processes to stop.
 
 Now put session_start() as the first line. Press RELOAD: it completes OK. Now press 
RELOAD again: it hangs !!! It waits for the sleep to terminate before starting the 
next !! So if you press RELOAD 10 times you need to wait 300 seconds !!
 
 Is it a normal behaviour ? How can I have a process completely in the background ?

That is by design (for file based session storage at least). 

See http://www.php.net/bugs.php?id=6287edit=1 and
http://bugs.php.net/?id=10675edit=1

All access to session variables in PHP4 is serialized. If you want to
start some daemon from inside your php script make it to close all
unused file handles at startup or close the session before exec().

oleg


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Bug #10675: Executing background job from PHP causes session lock-up

2001-05-05 Thread Oleg Makarenko

You probably use file based session storage, didn't you?

Then teach your backround script to close all file handles at startup as
every good daemon should do :).

PHP always locks the file session file when you open the session and
unlocks it only (by closing  it) when you close the session or the
script stops. The background process inherits the session file handle
from its parent and the session file remains locked thus preventing all
other apache processes to open/read it until your background script
dies. You can somehow close the session before starting your script in
background but still it is better to close all inherited file handles
that your script doesn't need.

oleg



[EMAIL PROTECTED] wrote:
 
 From: [EMAIL PROTECTED]
 Operating system: RedHat 6.2
 PHP version:  4.0.5
 PHP Bug Type: *Session related
 Bug description:  Executing background job from PHP causes session lock-up
 
 Executed a perl script in the background like this:
 perl scriptname.pl $otherParams 2 /dev/null 1 /dev/null
 
 Perl script forks and parent dies, so PHP should see the script as finished 
immediately, perl child does work in background (takes a few minutes to run).
 
 PHP script that spawned perl script completes OK, browser stops waiting for more 
data from php script as it should.
 
 However, when using the same browser window (or one from browser's file-new window) 
no other pages that referrence the session will load in the browser.  If we force the 
session to destroy just after the system() call, other scripts load just fine.  Also, 
other scripts work just fine if we start a new browser from scratch (creates new 
session).
 
 So it appears that the PHP session is getting messed up somehow b/c of the 
background system/exec/`` call.  This seems to prevent the following pages from 
loading the session properly and therefore they will not run.
 
 --
 Edit Bug report at: http://bugs.php.net/?id=10675edit=1
 
 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]