So, further testing indicates that it isn't PHP. The issue is if the calling script/process runs as a background process. My PHP script runs in IIS and uses a specific worker process with a specific user account to run. I created a VBScript:
Code: Select all
Dim printer, pdfname, cmd
printer = "LP46"
pdfname = "mypdf.pdf"
cmd = "cmd /C ""C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe"" /printto:showui=no " & printer & " e:\temppdfs\" & pdfname
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run cmd, 0, true
For my tests, I have created a test PDF that I can reuse indefinitely. I also did this with PHP (and wrote the same basic script as above in PHP, just to rule out the PDF creation process as a problem). If I run this script from the command line manually, it runs fine and closes. Same with the PHP script (i.e. php -f pdfprint.php).
However, if I run this as a background task (e.g. via Task Scheduler using the same account that the IIS worker process uses) the
PDFXCview.exe does not close out and the script hangs. With the PHP script, because it is being run by the IIS worker process, it runs as a background process as well.
For reference, I am running the latest version of PDF-XChange Viewer (v2.5.313.1) on Windows 2008R2 with latest updates (as of 1-JUL-2015). I have tested with PHP v5.5.8, 5.5.26, 5.6.0 & 5.6.10.
I'm not sure where to go from here. Because this process runs under IIS, I really don't have an option of running it as a "non-background" task. For the moment, I have changed the PHP script to not wait for the shell call to finish (i.e. $WshShell->Run($cmd,0,false); ) and disabled the automatic deletion of the PDF in the PHP script (deferring to a cleanup script that runs overnight). The issue is that this causes the worker process thread to stay open until it times out and recycles, which means that there is some resource utilization problems with that worker process & potentially multiple
PDFXCview.exe processes hanging open until they timeout. This process doesn't get called a lot, so it shouldn't be critical, but this isn't a good long term solution.
Any thoughts?
Thanks,
Eric