Re: Forking PHP on Windows 2003.

nc_at_iname.com
Date: 01/14/05


Date: 14 Jan 2005 11:31:51 -0800

Hopeless A wrote:
>
> We are attempting to fork a php script into a background
> php script and have the first scrip continue to completion.
> Is this even possible in the windows version of php?

Yes, if Windows itself allows it. You probably tried something
along the lines of:

exec('start C:\php\cli\php.exe C:\inetpub\wwwroot\background.php');

However, if you type HELP START from your Windows command prompt,
you may notice this bit:

If Command Extensions are enabled, external command
invocation through the command line or the START command
changes as follows:

...

When executing an application that is a 32-bit GUI
application, CMD.EXE does not wait for the application
to terminate before returning to the command prompt.
This new behavior does NOT occur if executing within
a command script.

My guess is that you have Command Extensions enabled, so
forking doesn't work. Try this:

exec('start cmd /E:OFF /C C:\php\cli\php.exe ' .
'C:\inetpub\wwwroot\background.php');

The /E:OFF switch will disable Command Extensions for the
duration of this command-line session, while the /C switch
will make sure the session will terminate after it's
complete...

> We have used the many code snippets floating around
> on the Internet claiming to fork on Windows, yet we
> never get it to work properly, sometimes ending up
> with hunderds of dead php.exe processes on the machine.

Are you sure you are using the correct php.exe? Rememeber,
there are two files named php.exe in PHP distribution,
the CGI executable (usually located in PHP root folder)
and the command-line interpreter (usually located in the
/CLI subfolder)...

Cheers,
NC



Relevant Pages

  • Re: OT: Old Windows command line...
    ... Actually, what I was trying to do was come up with a way of, under the Windows XP Pro command line, doing what is so easy to do under MPE in a batch job. ... Thus, I wrote a little PHP script that reads a "batch file" of my own format, which looks sort of like: ...
    (comp.sys.hp.mpe)
  • Re: IIS 6.0 on Windows Server 2003
    ... If PHP insists on using CMD.EXE to execute the shellcommand on the ... server, then no, you have no choice -- you must give read permissions to the ... this would be a security vulnerability caused by PHP. ...
    (microsoft.public.inetserver.misc)
  • Re: [PHP] ssh command in php script
    ... > I have written the following command in PHP script ... > when the execute the php file from the browser it does ... scalable system for accessing system services | ...
    (php.general)
  • [UNIX] PHP Allows Bypassing of safe_mode And Injecting ASCII Control Chars With mail()
    ... PHP is a widely used general-purpose scripting language that is especially ... vulnerabilities exists in mailPHP function. ... within a PHP script. ... allow specifying command line option to the sendmail binary. ...
    (Securiteam)
  • Re: Wnidows Server 2003 - I need help in getting the Connection Co
    ... command if already running. ... it fires off the netstat command for you, sending the results from that to ... another file which your PHP process can access. ... requires administator access we are get file permison problems - ANY IDEAS ...
    (microsoft.public.windowsmedia.server)