Click to See Complete Forum and Search --> : EXEC on win NT
Uttam
09-24-2002, 05:16 AM
Hello ,
I want to start a server on win NT thru exec() function of PHP.
but it is getting hanged everytime .
I tried running it as a background process too but the same result.
Does any body tell me how to acheive it.
a very simple version of the progmam I want to run is as follow:
main()
{
while(1);
}
dotwebbie
09-24-2002, 12:05 PM
I'm not sure I understand what you are trying to do . . . Is that it for the program you are trying to run? Have you tried running it from the command line instead of through php to ensure that it works?
Uttam
09-25-2002, 09:37 AM
There is a c executable which I want to run thru php.
It is some sort of server which keeps running in the background.
in unix I can acheive it by running it as a background process
exec( "myserver &" )
but on windows how can I acheive the same.
if I say
exec( "myserver" );
then PHP hangs because at that particular point because server keeps running there.
dotwebbie
09-25-2002, 10:00 AM
Out of curiousity, what's the extension of the myserver file?
Uttam
09-25-2002, 01:11 PM
sorry if my info is insufficient.
"myserver" is an executable file ("myserver.exe" on windows )
It has been tested from the command line it works as desired.
Its an single-threaded stateful component which keeps running in the background and keep serving requests from other client components.
So my PHP page is supposed to start it using exec( "myserver.exe") and leave it running in the win2000 system.
As I said before in unix it can be acheived by
exec( "myserver &") etc
how to acheive it on windows ?
dotwebbie
09-25-2002, 02:54 PM
That's better. :) I'm guessing myserver.exe is in the path, correct?
Uttam
09-26-2002, 12:54 PM
YES, it even starts the server which I can see in the task bar.
But I think that PHP's exec() function waits until server dies and thats the reason for hanging.
Because when I kill the process manually then immideately control returns back to the PHP page.
But in case of unix I can manage it by running it as a background process which is not working on windows.
dotwebbie
09-26-2002, 01:18 PM
So, myserver.exe is already started when you try to run exec()?
Uttam
09-27-2002, 04:31 AM
the 'server' starts with php's exec() function but the php code hangs there waiting for server to end.
A simple version of my problem
php code
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?
echo "before exec"; // it is executed.
exec("myserver.exe"); // here server starts but the exec function hangs here waiting for server to end when I manually kill the server then the next line is printed.
echo "after exec";// control reaches here only when the server is terminated.
?>
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
C code: 'myserver.c'
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
main()
{
while(1);
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
dotwebbie
09-27-2002, 10:41 AM
Okay, I get it now. Sorry it took so long. Just one of those weeks. :p I honestly have never run in to that problem. What version of php are you using? This might be something you want to ask on the php mailing list . . . :(
PHP Builder
Copyright Internet.com Inc. All Rights Reserved.