Reply to Re: exec hangs up sometimes

Your name:

Reply:


Posted by shimmyshack on 04/30/07 00:02

On Apr 29, 9:06 pm, wart...@hotmail.com wrote:
> This is a quite misterious problem. I have a php-script that first
> calls an executable program with
> $ret = exec('program.exe');
>

depends on how "good" you program is, it must return if it fails,
thats the minimum, otherwise php will wait of course.

> and then continues outputting html. Well, most of the times it workes
> fine. But sometime, without any speciual reasons, something goes
> wrong. And when something goes wrong it becomes a real problem. Yes,
> because nest time I run the script then it will hang up. The script
> waits for the response from the exe-program, but never gets it. At the
> end the page will timeout. This is not good.

you must not require the return from the program before outputting
html, if the program is capable of hanging, you could get round this
by recoding the app, running a "helper" app that will exe the program,
timingout and returning a default.
OR use an ifram so that if the program timesout it wont affect the
whole page. Of course if the program returns a value which affects the
html and you cannot recode the prog, depending on ho MUCH html is
affected you could have the master html with javascript wait for the
iframe to return some javascript with the value from the program, if
it doesnt do this in time (say 2secs) it calls a second iframe which
returns the script, this script populates the master page.

you could also try passthru and system, and use system( 'program.exe
&2>1' ) to force an error out to stream to std out, this might help.

without specific details I cant ehlp further, but the fact that safe
mode is ON worries me somewhat, get rid of that for a start, also exec
hangs is not something I have ever come across, (>4years WAMP admin) I
think its far more likely that your apache child is hanging. As with
piping logs through processes, so with calling processes, make sure
your process is well written if its a show stopper when it fails.

>
> After this has happen I am not able to run any script that will use
> the exec-command. Doesnt matter what exe I will call. The .exe-file
> works without any problem even after the problem with the script
> occured.
>
> The only thing I can do right now, in order to make the exec-command
> to work again, is to restart apache. For the kind of application Im
> developing this is not an acceptable solution.
>
> I dont think this has something to do with safe mode. I guess that it
> would not allow exec at all if set as OFF. Anybody with a good advice?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация