So happens that I am writing a PHP front-end for SPASM. (if you visit Omnimaga or Revsoft, you had noticed)

I got it coded and tested under Windows (using XAMPP and I am going to test on Linux sometime but that is a different issue)

The only problem is if SPASM process never ends (some bug or macro that loops forever) the script will never echo content and worse a spasm process is still running in the server. This can be disastrous, how many times a server needs normally reboots?

Basically I can't use the system(), exec(), passthru(), shell_exec() and popen() functions.
So proc_open() seems the way to go but the only problem is that I can't get SPASM working right and it doesn't output anything.

See the download and try to fix the code, say what is wrong or an alternative.
The code relates to the code counter using SPASM. Some docs and miscellaneous stuff is provided.
Download OnlineAssembler source code

I had enough unfruitful time lost before calling for help.
Just set your PHP scripts timeout to something pretty low, like 10 seconds. You can set a lower limit at run time in your script just fine.

But a better solution would be to not use SPASM and use something less buggy. Maybe BRASS?
Kllrnohj wrote:
Just set your PHP scripts timeout to something pretty low, like 10 seconds. You can set a lower limit at run time in your script just fine.

But a better solution would be to not use SPASM and use something less buggy. Maybe BRASS?

That doesn't solve the problem. spasm process still runs... use task manager to see it. Although I haven't be able to do spasm loop forever, but I think I managed long ago... but it is somewhat risky to trust on that. I use the batch file to simulate a process that never exits and consume cpu.
And set_time_limit(3); doesn't solve everything... And in most hosts you can't edit php.ini.
When PHP calls the shell_exec() and identical functions, the script only runs after the command ends.

I could try BRASS but I don't know much about it...
An infinite loop would be bug that you should email the author about. If it isn't something you can reproduce anymore, assume that the bug is fixed and don't worry about it.
I did it! Surprised

Fixed the code. Thanks any way.

The bug was solved by changing this:
proc_open("spasm -C -O -N $tmpfnam", $descriptorspec, $pipes);

To this:
proc_open("spasm -C -O -N ".$tmpfnam." 2>&1", $descriptorspec, $pipes);
And changing accordingly the rest of the code.

It now cleanly kills spasm or whatever process doesn't stop. Tested under Windows, Linux remains but should work because I am using proc_terminate that should be cross platform.

I only managed to debug this because of a script I found around that outputted important info of the proc_open() procedure.
Nicely done, Galandros! So when do we get to try out this online assembler of yours? Smile
KermMartian wrote:
Nicely done, Galandros! So when do we get to try out this online assembler of yours? Smile

There is still some time consuming things to do because it will need search on google, several tries and sweating to cross compile SPASM to some Linux server. I need to figure out by searching how to do this.
I currently have two offers of hosting in the calc community.

Apart from this hard task, it remains some PHP coding too. Oh, I expect to get it online this month.

If I got some free Windows hosting with PHP (I can almost feel the karma change because of talking of Windows hosting and PHP together) I could put right away the Z80 Assembly Online Code Counter into action.
I wasn't able to host the Z80 Online Assembler myself, sorry. Sad

I forgot a bit about this but yesterday and today I quickly added the pieces to have a beta of the Z80 Online Assembler. It is tested under Windows and works. Under Linux it has some testing (and predictable bugs corrected) but not totally tested...
It supports up to 15 file of source including .inc, .bmp and .bin files because SPASM is great. It has a limit on size, though. (around 20kb IIRC)

Download the source, read the readme and good luck. If you get it working in the Internet, shout me about it!
http://galandrosdev.2kool4u.net/files/CalcUtils.zip

If someone successfully host it, I will finish most things of the ToDo list in the readme. Wink
Neat, Galandros, congrats for making this much progress on it. I'll definitely give it a try, although I only host things under Linux environments.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement